当前位置: 首页>>代码示例>>Python>>正文


Python crypto.load_pkcs7_data方法代码示例

本文整理汇总了Python中OpenSSL.crypto.load_pkcs7_data方法的典型用法代码示例。如果您正苦于以下问题:Python crypto.load_pkcs7_data方法的具体用法?Python crypto.load_pkcs7_data怎么用?Python crypto.load_pkcs7_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSSL.crypto的用法示例。


在下文中一共展示了crypto.load_pkcs7_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_ca

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_create_ca(self):
        subca_dict = self._create_subca()
        self.assertEqual("sub ca1", subca_dict.get(cm.INFO_NAME))
        self.assertIsNotNone(subca_dict.get(cm.INFO_EXPIRATION))
        self.assertIsNotNone(subca_dict.get(cm.PLUGIN_CA_ID))
        ca_cert = subca_dict.get(cm.INFO_CA_SIGNING_CERT)
        self.assertIsNotNone(ca_cert)

        intermediates = subca_dict.get(cm.INFO_INTERMEDIATES)
        self.assertIsNotNone(intermediates)

        cacert = crypto.load_certificate(crypto.FILETYPE_PEM, ca_cert)
        subject = cacert.get_subject()
        self.assertEqual(
            "subordinate ca signing cert",
            subject.CN)

        pkcs7 = crypto.load_pkcs7_data(crypto.FILETYPE_PEM, intermediates)
        self.assertTrue(pkcs7.type_is_signed())

        # TODO(alee) Verify that ca cert is signed by parent CA 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:23,代码来源:test_snakeoil_ca.py

示例2: _parse

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def _parse(self, buff, digestalgo):
        pkcs7 = crypto.load_pkcs7_data(crypto.FILETYPE_ASN1, buff)

        certs_stack = _ffi.NULL
        if pkcs7.type_is_signed():
            certs_stack = pkcs7._pkcs7.d.sign.cert
        elif pkcs7.type_is_signedAndEnveloped():
            certs_stack = pkcs7._pkcs7.d.signed_and_enveloped.cert

        pycerts = []

        for i in range(_lib.sk_X509_num(certs_stack)):
            tmp = _lib.X509_dup(_lib.sk_X509_value(certs_stack, i))
            pycert = X509._from_raw_x509_ptr(tmp)
            pycerts.append(pycert)

        if not pycerts:
            return None

        for cert in pycerts:
            name = str(cert.get_subject())[19:-2].replace('/', ', ')
            checksum = cert.digest(digestalgo).decode().replace(':', '')

            self.content.append((name, checksum)) 
开发者ID:mikusjelly,项目名称:apkutils,代码行数:26,代码来源:cert.py

示例3: test_type_is_signedAndEnveloped_wrong_args

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_signedAndEnveloped_wrong_args(self):
        """
        :py:obj:`PKCS7Type.type_is_signedAndEnveloped` raises :py:obj:`TypeError` if called
        with any arguments.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertRaises(TypeError, pkcs7.type_is_signedAndEnveloped, None) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例4: test_type_is_signedAndEnveloped

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_signedAndEnveloped(self):
        """
        :py:obj:`PKCS7Type.type_is_signedAndEnveloped` returns :py:obj:`False` if the PKCS7
        object is not of the type *signed and enveloped*.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertFalse(pkcs7.type_is_signedAndEnveloped()) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例5: test_load_pkcs7_data_pem

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_load_pkcs7_data_pem(self):
        """
        :py:obj:`load_pkcs7_data` accepts a PKCS#7 string and returns an instance of
        :py:obj:`PKCS7Type`.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertTrue(isinstance(pkcs7, PKCS7Type)) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例6: test_load_pkcs7_data_asn1

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_load_pkcs7_data_asn1(self):
        """
        :py:obj:`load_pkcs7_data` accepts a bytes containing ASN1 data
        representing PKCS#7 and returns an instance of :py:obj`PKCS7Type`.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_ASN1, pkcs7DataASN1)
        self.assertTrue(isinstance(pkcs7, PKCS7Type)) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例7: test_load_pkcs7_data_invalid

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_load_pkcs7_data_invalid(self):
        """
        If the data passed to :py:obj:`load_pkcs7_data` is invalid,
        :py:obj:`Error` is raised.
        """
        self.assertRaises(Error, load_pkcs7_data, FILETYPE_PEM, b"foo") 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:8,代码来源:test_crypto.py

示例8: test_type_is_signed_wrong_args

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_signed_wrong_args(self):
        """
        :py:obj:`PKCS7Type.type_is_signed` raises :py:obj:`TypeError` if called with any
        arguments.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertRaises(TypeError, pkcs7.type_is_signed, None) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例9: test_type_is_signed

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_signed(self):
        """
        :py:obj:`PKCS7Type.type_is_signed` returns :py:obj:`True` if the PKCS7 object is of
        the type *signed*.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertTrue(pkcs7.type_is_signed()) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例10: test_type_is_enveloped

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_enveloped(self):
        """
        :py:obj:`PKCS7Type.type_is_enveloped` returns :py:obj:`False` if the PKCS7 object is
        not of the type *enveloped*.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertFalse(pkcs7.type_is_enveloped()) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例11: test_type_is_data

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_data(self):
        """
        :py:obj:`PKCS7Type.type_is_data` returns :py:obj:`False` if the PKCS7 object is not of
        the type data.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertFalse(pkcs7.type_is_data()) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例12: test_type_is_data_wrong_args

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_type_is_data_wrong_args(self):
        """
        :py:obj:`PKCS7Type.type_is_data` raises :py:obj:`TypeError` if called with any
        arguments.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertRaises(TypeError, pkcs7.type_is_data, None) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例13: test_get_type_name

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_get_type_name(self):
        """
        :py:obj:`PKCS7Type.get_type_name` returns a :py:obj:`str` giving the type name.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertEquals(pkcs7.get_type_name(), b('pkcs7-signedData')) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:8,代码来源:test_crypto.py

示例14: test_attribute

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def test_attribute(self):
        """
        If an attribute other than one of the methods tested here is accessed on
        an instance of :py:obj:`PKCS7Type`, :py:obj:`AttributeError` is raised.
        """
        pkcs7 = load_pkcs7_data(FILETYPE_PEM, pkcs7Data)
        self.assertRaises(AttributeError, getattr, pkcs7, "foo") 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:9,代码来源:test_crypto.py

示例15: verify_valid_intermediates

# 需要导入模块: from OpenSSL import crypto [as 别名]
# 或者: from OpenSSL.crypto import load_pkcs7_data [as 别名]
def verify_valid_intermediates(self, secret_ref):
        secret_resp = self.secret_behaviors.get_secret(
            secret_ref,
            "application/pkix-cert")
        self.assertIsNotNone(secret_resp)
        self.assertIsNotNone(secret_resp.content)
        cert_chain = secret_resp.content
        crypto.load_pkcs7_data(crypto.FILETYPE_PEM, cert_chain) 
开发者ID:cloud-security-research,项目名称:sgx-kms,代码行数:10,代码来源:test_certificate_orders.py


注:本文中的OpenSSL.crypto.load_pkcs7_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。