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


Python ExtensionOID.SUBJECT_ALTERNATIVE_NAME属性代码示例

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


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

示例1: match

# 需要导入模块: from cryptography.x509.oid import ExtensionOID [as 别名]
# 或者: from cryptography.x509.oid.ExtensionOID import SUBJECT_ALTERNATIVE_NAME [as 别名]
def match(self, value):
        # This is somewhat terrible. Probably can be better after
        # pyca/service_identity#14 is resolved.
        target_ids = [
            DNSPattern(target_name.encode('utf-8'))
            for target_name
            in (
                value.extensions
                .get_extension_for_oid(
                    ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
                .value
                .get_values_for_type(x509.DNSName)
            )]
        ids = [DNS_ID(self.name)]
        try:
            verify_service_identity(
                cert_patterns=target_ids, obligatory_ids=ids, optional_ids=[])
        except VerificationError:
            return Mismatch(
                '{!r} is not valid for {!r}'.format(value, self.name)) 
开发者ID:twisted,项目名称:txacme,代码行数:22,代码来源:matchers.py

示例2: request_issuance

# 需要导入模块: from cryptography.x509.oid import ExtensionOID [as 别名]
# 或者: from cryptography.x509.oid.ExtensionOID import SUBJECT_ALTERNATIVE_NAME [as 别名]
def request_issuance(self, csr):
        csr = csr.csr
        # TODO: Only in Cryptography 1.3
        # assert csr.is_signature_valid
        cert = (
            x509.CertificateBuilder()
            .subject_name(csr.subject)
            .issuer_name(self._ca_name)
            .not_valid_before(self._now() - timedelta(seconds=3600))
            .not_valid_after(self._now() + timedelta(days=90))
            .serial_number(int(uuid4()))
            .public_key(csr.public_key())
            .add_extension(
                csr.extensions.get_extension_for_oid(
                    ExtensionOID.SUBJECT_ALTERNATIVE_NAME).value,
                critical=False)
            .add_extension(
                x509.SubjectKeyIdentifier.from_public_key(csr.public_key()),
                critical=False)
            .add_extension(self._ca_aki, critical=False)
            .sign(
                private_key=self._ca_key,
                algorithm=hashes.SHA256(),
                backend=default_backend()))
        cert_res = messages.CertificateResource(
            body=cert.public_bytes(encoding=serialization.Encoding.DER))
        return self._controller.issue().addCallback(lambda _: cert_res) 
开发者ID:twisted,项目名称:txacme,代码行数:29,代码来源:testing.py

示例3: subject_alternative_name

# 需要导入模块: from cryptography.x509.oid import ExtensionOID [as 别名]
# 或者: from cryptography.x509.oid.ExtensionOID import SUBJECT_ALTERNATIVE_NAME [as 别名]
def subject_alternative_name(self):
        ext = self.get_x509_extension(ExtensionOID.SUBJECT_ALTERNATIVE_NAME)
        if ext is not None:
            return SubjectAlternativeName(ext) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:6,代码来源:models.py

示例4: subject_alt_name

# 需要导入模块: from cryptography.x509.oid import ExtensionOID [as 别名]
# 或者: from cryptography.x509.oid.ExtensionOID import SUBJECT_ALTERNATIVE_NAME [as 别名]
def subject_alt_name(self):
        """
        Extract certificate's alt names

        :return: unicode
        """
        try:
            alt_names = self.x509.extensions.get_extension_for_oid(ExtensionOID.SUBJECT_ALTERNATIVE_NAME).value
            alt_name_strings = [alt_name.value for alt_name in alt_names]
            return ",".join(alt_name_strings)
        except x509.ExtensionNotFound:
            return "(no subject alt name)" 
开发者ID:mozilla,项目名称:tls-canary,代码行数:14,代码来源:cert.py


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