【问题标题】:Import Public Key from GameCenter using PyCrypto on Google App Engine在 Google App Engine 上使用 PyCrypto 从 GameCenter 导入公钥
【发布时间】:2015-01-07 01:58:34
【问题描述】:

我正在尝试使用 Apple 记录的方法验证远程服务器上的 GameCenter 播放器:

GKLocalPlayer generateIdentityVerificationSignatureWithCompletionHandler:

在 iOS 上调用此方法会返回一个指向此文件的链接(此文件位置相当静态,您可以下载它以查看其内容):

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

此文件包含必须下载到服务器上以开始本地 GameCenter 播放器的验证过程的公钥。

我在我的项目中使用 Google App Engine,这限制了我使用 PyCrypto 库。我正在尝试使用这些调用导入此文件(为了清楚起见,我直接在此处使用文件名):

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) 

很遗憾,此操作失败并显示以下消息:

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

据我了解,PyCrypto 需要一个 DER 格式的证书,我认为这是 Apple 提供的。有谁知道我做错了什么,或者可以指出我正确的方向?谢谢。

另外,我已将我的 GAE 项目设置为使用最新版本的 PyCrypto,我认为是 2.6。

事实证明,使用 Google App Engine 获得 GameCenter 身份验证的过程非常麻烦。

【问题讨论】:

    标签: ios google-app-engine game-center pycrypto


    【解决方案1】:

    事实证明,原因是从 Apple 下载的文件实际上是 X.509 证书。必须先从该证书中提取公钥,然后才能使用它。这个答案在类似的帖子中得到了证明:

    How do I use a X509 certificate with PyCrypto?

    有关使用 Google App Engine 验证 GameCenter 用户的完整解决方案,请参阅我在这篇文章中的回答:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-15
      • 1970-01-01
      • 2012-04-02
      • 1970-01-01
      • 2019-09-03
      相关资源
      最近更新 更多