python: APNs SSLError

前端 未结 2 666
轻奢々
轻奢々 2020-12-23 11:01

I am trying to send push notifications to iPhone via python as described here but I am getting the following error:

Traceback (most recent call last):
  File         


        
相关标签:
2条回答
  • 2020-12-23 11:27

    I ran into the same error message using PyAPNs. The example says to initiate it like this:

    apns = APNs(use_sandbox=True, cert_file='cert.pem', key_file='key.pem')
    

    Turns out the solution to my problem was to include the full system path for each .pem file:

    cert_path = os.path.join(os.path.dirname(__file__), 'cert.pem')
    key_path = os.path.join(os.path.dirname(__file__), 'key.pem')
    apns = APNs(use_sandbox=True, cert_file=cert_path, key_file=key_path)
    
    0 讨论(0)
  • 2020-12-23 11:28

    Here is how I get it working:

    From within KeyChain export the following both in p12 format, without giving password:

    • Apple Development Push Services certificate as cert.p12
    • primary key under Apple Development Push Services as pkey.p12

    In terminal go to the directory where you have exported the certificates and convert the p12 files to pem format and concatenate them as follows:

    $ openssl pkcs12 -in pkey.p12 -out pkey.pem -nodes -clcerts
    $ openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts
    $ cat cert.pem pkey.pem > iphone_ck.pem
    

    iphone_ck.pem is the certificate you need.

    0 讨论(0)
提交回复
热议问题