Skip to content

Instantly share code, notes, and snippets.

@wbond
Last active February 8, 2017 14:38
Show Gist options
  • Save wbond/e670565ced8949d879197be9b41c0239 to your computer and use it in GitHub Desktop.
Save wbond/e670565ced8949d879197be9b41c0239 to your computer and use it in GitHub Desktop.
from asn1crypto.csr import CertificationRequest
cr = CertificationRequest.load(der_bytes)
attrs = cr['certification_request_info']['attributes']
print(attrs.native)

The fields are defined at https://github.com/wbond/asn1crypto/blob/master/asn1crypto/csr.py. Depending on your needs, you could duplicate the definitions with OID and spec data for your custom extensions.

That said, the code above doesn't actually do any validation of the CSR. That should be done before accessing the information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment