keyview.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:keyview 作者: ALSchwalm 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号