Q:

Apple FairPlay Key Server Module Implementation

Has anybody managed to implement this part? Apple has released some reference code along with the FairPlay SDK (preview), but there are quite some missing bits. Is there any guides / tutorials, which would help / guide the implementation?

A:

The most troublesome part of the reference is that it's missing the private key which they say to just put in some array. PROBLEM: the key is in a pem file and has a textual represntation.
After a little bit of testing I was able to overcome this.
I took the relevant .pem file which starts with the line "-----BEGIN RSA PRIVATE KEY-----" and then the base64 encoded key and finishes with "-----END RSA PRIVATE KEY-----" so I just took all the data (including opening and closing lines) and converted it to a bytes represntation.
I used the following python code
file = open("dev_private_key.pem", "r")
a = file.read()
b = new bytearray(a)
for ch in b:
  sys.stdout.write(str(ch)+",")

Then I took this output and just pasted it in the required line in SKDServerUtils.c so it looks something like this
static const UInt8 pKeyPem[] = {45,45,45,45,45....}
Recompiled it all and it works well for me.
Hope this helps people in the future since I couldn't find any better documentation on this specific part.

