def get_pkcs7_certificates(bundle):
from OpenSSL._util import (
ffi as _ffi,
lib as _lib
)
from OpenSSL.crypto import X509
certs = _ffi.NULL
if bundle.type_is_signed():
certs = bundle._pkcs7.d.sign.cert
elif bundle.type_is_signedAndEnveloped():
certs = bundle._pkcs7.d.signed_and_enveloped.cert
pycerts = []
for i in range(_lib.sk_X509_num(certs)):
pycert = X509.__new__(X509)
pycert._x509 = _ffi.gc(_lib.X509_dup(_lib.sk_X509_value(certs, i)), _lib.X509_free)
pycerts.append(pycert)
if not pycerts:
return tuple()
return tuple(pycerts)
评论列表
文章目录