Python MDM:如何使用APNS证书

Python MDM:如何使用APNS证书,python,ios,mdm,Python,Ios,Mdm,我已使用iOS Enterprise developer帐户收到APNS证书,该证书为.pem格式。我们已从门户下载此mdm证书 我已经参考了2011年的iOS MDM协议文档来实现MDM服务器。我能够获得pushmagic和设备令牌 我使用“2011\u iOS MDM协议”文档中给出的以下代码作为server.py文件 class queue_cmd: def GET(self): global current_command, last_sent global my_DeviceToken

我已使用iOS Enterprise developer帐户收到APNS证书,该证书为.pem格式。我们已从门户下载此mdm证书

我已经参考了2011年的iOS MDM协议文档来实现MDM服务器。我能够获得pushmagic和设备令牌

我使用“2011\u iOS MDM协议”文档中给出的以下代码作为server.py文件

class queue_cmd: def GET(self):
global current_command, last_sent global my_DeviceToken, my_PushMagic 
i = web.input() cmd = i.command
cmd_data = mdm_commands[cmd] 
cmd_data['CommandUUID'] = str(uuid.uuid4()) 
current_command = cmd_data last_sent = pprint.pformat(current_command)
wrapper = APNSNotificationWrapper('PlainCert.pem', False) 
message = APNSNotification() 
message.token(my_DeviceToken) 
message.appendProperty(APNSProperty('mdm', my_PushMagic))   
wrapper.append(message)
wrapper.notify()

现在我想知道,我应该使用从门户网站下载的APNS证书,在server.py代码中将其重命名为“PlainCert.pem”,还是通过其他方式生成“PlainCert.pem”?这里有一个文档应该会有所帮助

从apple下载的APNS证书应包含证书的公钥部分。 您需要将它与私钥结合起来,以生成一个完整的.p12 pem文件。 这应该是代码所讨论的PlainCert.pem

也请点击此链接:

并从customerPrivateKey.pem中删除密码短语 使用此命令

openssl rsa -in customerPrivateKey.pem -out PlainKey.pem
cat CustomerCompanyName.pem PlainKey.pem > PlainCert.pem
然后使用以下命令合并从门户下载的APNS证书(例如CustomerCompanyName.pem

openssl rsa -in customerPrivateKey.pem -out PlainKey.pem
cat CustomerCompanyName.pem PlainKey.pem > PlainCert.pem

现在,这个PlainCert.pem文件可以在您的服务器代码中使用。

我为MDM生成了推送证书。它有一个有效的主题。在keychain store中查看时,会显示“此证书由未知机构签署”。也没有与之关联的私钥。知道怎么了吗?