我有西班牙权威机构(FNMT)颁发的有效证书,我想用它来了解更多信息。
该文件的扩展名是.p12
我想阅读其中的信息(名字和姓氏)并检查证书是否有效。可以用 pyOpenSSL 做到这一点吗?我想我必须使用 OpenSSL 中的加密模块。
有任何帮助或有用的链接吗?尝试在这里阅读:http://packages.python.org/pyOpenSSL/openssl-crypto.html http://packages.python.org/pyOpenSSL/openssl-crypto.html但信息不多:-(
使用起来相当简单。这未经测试,但应该有效:
# load OpenSSL.crypto
from OpenSSL import crypto
# open it, using password. Supply/read your own from stdin.
p12 = crypto.load_pkcs12(open("/path/to/cert.p12", 'rb').read(), passwd)
# get various properties of said file.
# note these are PyOpenSSL objects, not strings although you
# can convert them to PEM-encoded strings.
p12.get_certificate() # (signed) certificate object
p12.get_privatekey() # private key.
p12.get_ca_certificates() # ca chain.
有关更多示例,请查看pyopenssl的单元测试代码 http://nullege.com/codes/show/src@p@y@pyOpenSSL-0.10@test@test_crypto.py/22/OpenSSL.crypto.PKCS12Type/python。几乎您想要使用该库的所有方式都在那里
也可以看看here http://nullege.com/codes/search/OpenSSL或无广告here https://github.com/pyca/pyopenssl/blob/master/tests/test_crypto.py.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)