0

I'm trying to verify a GameCenter player on a remote server using Apple's documented method:

GKLocalPlayer generateIdentityVerificationSignatureWithCompletionHandler:

Calling this method on iOS returns, among other things, a link to this file (this file location is fairly static, and you can download it to see its contents):

https://sandbox.gc.apple.com/public-key/gc-sb.cer

This file holds the public key that must be downloaded on the server to begin the verification process for the local GameCenter player.

I am using Google App Engine for my project, which limits me to using the PyCrypto library. I am trying to import this file using these calls (I use the filename directly here for clarity):

from Crypto.PublicKey import RSA 

apple_cert = urllib2.urlopen("https://sandbox.gc.apple.com/public-key/gc-sb.cer").read()
rsakey = RSA.importKey(apple_cert) 

Unfortunately, this is failing with the following message:

raise ValueError("RSA key format is not supported")

From what I understand, PyCrypto is expecting a DER formatted certificate, which is what I think Apple is supplying. Does anyone know what I'm doing wrong, or can point me in the right direction? Thanks.

Also, I have setup my GAE project to use the latest version of PyCrypto, which I think is 2.6.

The process of getting GameCenter authentication working with Google App Engine is proving to be very troublesome.

Shaun Budhram
  • 3,690
  • 4
  • 30
  • 41

1 Answers1

0

As it turns out, the reason is because the file downloaded from Apple is actually an X.509 certificate. The public key has to be extracted from this certificate before it can be used. This answer is demonstrated in a similar post:

How do I use a X509 certificate with PyCrypto?

For the full solution on validating a GameCenter user using Google App Engine, see my answer in this post:

How to authenticate the GKLocalPlayer on my 'third party server'?

Community
  • 1
  • 1
Shaun Budhram
  • 3,690
  • 4
  • 30
  • 41