android - Is there any python package for parsing pkcs7? -


i'm extracting features android .apk files androguard , right need extract serial number(*) signature file (usually cert.rsa). i've found asn1crypto, don't quite understand, how use pkcs7. there python package suitable purpose?

(*): serial number

comment: have pkcs7 memory object, not file

pyopenssl not read file!

openssl.crypto.load_pkcs7_data(type, buffer)

load pkcs7 data string buffer encoded type type.
type type must either filetype_pem or filetype_asn1).

from openssl import crypto pkcs7 = crypto.load_pkcs7_data(crypto.filetype_asn1,                                 open('certs/signature.der', 'rb').read()) certs = get_certificates(pkcs7) cert in certs:     print('subject:{}, serial nnumber:{}'.         format(cert.get_subject(), cert.get_serial_number()))  >>>subject:<x509name object '/cn=key1'>, serial nnumber:13315126025841024674 >>>subject:<x509name object '/cn=key2'>, serial nnumber:14142490995367396705 

question: python package parsing pkcs7?

you can convert pkcs#7 pem using openssl, pem readable using pyopenssl

openssl pkcs7 -print_certs -in sample.p7b -out sample.cer 

read relevant answer: pyopenssl's pkcs7


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -