test_crypto.py 文件源码

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

项目:2FAssassin 作者: maxwellkoh 项目源码 文件源码
def test_extension_count(self):
        """
        `X509.get_extension_count` returns the number of extensions
        that are present in the certificate.
        """
        pkey = load_privatekey(FILETYPE_PEM, client_key_pem)
        ca = X509Extension(b'basicConstraints', True, b'CA:FALSE')
        key = X509Extension(b'keyUsage', True, b'digitalSignature')
        subjectAltName = X509Extension(
            b'subjectAltName', True, b'DNS:example.com')

        # Try a certificate with no extensions at all.
        c = self._extcert(pkey, [])
        assert c.get_extension_count() == 0

        # And a certificate with one
        c = self._extcert(pkey, [ca])
        assert c.get_extension_count() == 1

        # And a certificate with several
        c = self._extcert(pkey, [ca, key, subjectAltName])
        assert c.get_extension_count() == 3
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号