Apple Store Server Notification: Python OpenSSL certificate loading fails in "header too long"

64 Views Asked by At

On my django server, I'm trying to decode the JWT content sent by the Apple Store Server Notification using Apple's package app-store-server-library-python.

Under the official documentation, when starting to do the verification and decoding, we find this line:

root_certificates = load_root_certificates()

The implementation is not provided unfortunately. By looking here and there, I've tried several implementations that always fail in :

OpenSSL.crypto.Error: [('asn1 encoding routines', '', 'header too long')]

Here is my implementation:

def load_root_certificates():
    in_file = open("AppleRootCA-G3.cer", "rb")
    data = in_file.read()
    in_file.close()
    return load_certificate(FILETYPE_ASN1, data)

What could be the cause of the issue here? Thanks for the help!

0

There are 0 best solutions below