當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。