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