Python прочитал Apple push-уведомление cert.p12
#!/usr/bin/python
# -*- coding: utf-8 -*-
#coding:utf8
from OpenSSL import crypto
class CertToString(object):
def __init__(self):
pass
def dump_certificate(self):
p12 = crypto.load_pkcs12(file(r'cert.p12','rb').read(), '')
p12_certificate = p12.get_certificate()
p12_privatekey = p12.get_privatekey()
certificate = crypto.dump_certificate(crypto.FILETYPE_PEM, p12_certificate)
private_key = crypto.dump_privatekey(crypto.FILETYPE_PEM, p12_privatekey,)
print certificate
print private_key
if __name__ == "__main__":
certToStr = CertToString()
certToStr.dump_certificate()
распечатать результат:
-----BEGIN CERTIFICATE-----
xxxxxxxxxxx
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
xxxxxxxxxx
-----END RSA PRIVATE KEY-----
openssl convert apple push notification cert.p12 to cert.pem in command:
$)openssl pkcs12 -in cert.p12 -out cert.pem -nodes
$)cat cert.pem
Bag Attributes
friendlyName: xxxxxxxxx
localKeyID: xxxxxxxxx
subject=xxxxxx
issuer=xxxxxxx
-----BEGIN CERTIFICATE-----
xxxxxxxxxxx
-----END CERTIFICATE-----
Bag Attributes
friendlyName: xxxx
localKeyID: xxxxxxx
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
xxxxxxxxxxx
-----END PRIVATE KEY-----
файл pem есть "-----BEGIN CERTIFICATE-----xxxx-----END CERTIFICATE-----"
а также"-----BEGIN PRIVATE KEY-----xxxxxxxxxxx-----END PRIVATE KEY-----
", закрытый ключ и python dump_privatekey не совпадают, но aws sns
необходимость "PRIVATE KEY
"не тот"RSA PRIVATE KEY
как можно получить cert.p12
"PRIVATE KEY
"в питоне?