Exemple #1
0
    def __init__(self, extension):
        self.id = tuple_to_OID(extension.getComponentByName("extnID"))
        critical = extension.getComponentByName("critical")
        self.is_critical = (critical != 0)
        self.ext_type = None

        # set the bytes as the extension value
        self.value = extension.getComponentByName("extnValue")._value

        # if we know the type of value, parse it
        decoderTuple = Extension._extensionDecoders.get(self.id)
        if decoderTuple is not None:
            try:
                (decoderAsn1Spec, decoderFunction, extType) = decoderTuple
                v = decode(self.value, asn1Spec=decoderAsn1Spec)[0]
                self.value = decoderFunction(v)
                self.ext_type = extType
            except PyAsn1Error:
                #According to RFC 5280, unrecognized extension can be ignored
                #unless marked critical, though it doesn't cover all cases.
                if self.is_critical:
                    raise
        elif self.is_critical:
            raise CertificateError("Critical extension OID %s not understood" %
                                   self.id)
Exemple #2
0
 def __init__(self, asn1_certPol):
     self.id = tuple_to_OID(
         asn1_certPol.getComponentByName("policyIdentifier"))
     self.qualifiers = []
     if (asn1_certPol.getComponentByName("policyQualifiers")):
         qualifiers = asn1_certPol.getComponentByName("policyQualifiers")
         self.qualifiers = [PolicyQualifier(pq) for pq in qualifiers]
Exemple #3
0
 def __init__(self, asn1_authInfo):
     self.id = tuple_to_OID(
         asn1_authInfo.getComponentByName("accessMethod"))
     self.access_location = str(
         asn1_authInfo.getComponentByName("accessLocation").getComponent())
     self.access_method = AuthorityInfoAccessExt._accessMethods.get(self.id)
     pass
Exemple #4
0
    def __init__(self, asn1_pQual):
        self.id = tuple_to_OID(asn1_pQual.getComponentByName("policyQualifierId"))
        if asn1_pQual.getComponentByName("qualifier") is not None:
            qual = asn1_pQual.getComponentByName("qualifier")
            self.qualifier = None
            # this is a choice - only one of following types will be non-null

            comp = qual.getComponentByName("cpsUri")
            if comp is not None:
                self.qualifier = str(comp)
Exemple #5
0
    def __init__(self, asn1_pQual):
        self.id = tuple_to_OID(
            asn1_pQual.getComponentByName("policyQualifierId"))
        if asn1_pQual.getComponentByName("qualifier") is not None:
            qual = asn1_pQual.getComponentByName("qualifier")
            self.qualifier = None
            # this is a choice - only one of following types will be non-null

            comp = qual.getComponentByName("cpsUri")
            if comp is not None:
                self.qualifier = str(comp)
Exemple #6
0
    def __init__(self, extension):
        self.id = tuple_to_OID(extension.getComponentByName("extnID"))
        critical = extension.getComponentByName("critical")
        self.is_critical = (critical != 0)
        self.ext_type = None

        # set the bytes as the extension value
        self.value = extension.getComponentByName("extnValue")._value

        # if we know the type of value, parse it
        decoderTuple = Extension._extensionDecoders.get(self.id)
        if decoderTuple is not None:
            try:
                (decoderAsn1Spec, decoderFunction, extType) = decoderTuple
                v = decode(self.value, asn1Spec=decoderAsn1Spec)[0]
                self.value = decoderFunction(v)
                self.ext_type = extType
            except PyAsn1Error:
                #According to RFC 5280, unrecognized extension can be ignored
                #unless marked critical, though it doesn't cover all cases.
                if self.is_critical:
                    raise
        elif self.is_critical:
            raise CertificateError("Critical extension OID %s not understood" % self.id)
Exemple #7
0
 def __init__(self, asn1_certPol):
     self.id = tuple_to_OID(asn1_certPol.getComponentByName("policyIdentifier"))
     self.qualifiers = []
     if (asn1_certPol.getComponentByName("policyQualifiers")):
         qualifiers = asn1_certPol.getComponentByName("policyQualifiers")
         self.qualifiers = [PolicyQualifier(pq) for pq in qualifiers]
Exemple #8
0
 def __init__(self, asn1_authInfo):
     self.id = tuple_to_OID(asn1_authInfo.getComponentByName("accessMethod"))
     self.access_location = str(asn1_authInfo.getComponentByName("accessLocation").getComponent())
     self.access_method = AuthorityInfoAccessExt._accessMethods.get(self.id)
     pass
Exemple #9
0
    def __init__(self, asn1_extKeyUsage):
        usageOIDs = set([tuple_to_OID(usageOID) for usageOID in asn1_extKeyUsage])

        for (oid, attr) in ExtendedKeyUsageExt._keyPurposeAttrs.items():
            setattr(self, attr, oid in usageOIDs)
Exemple #10
0
    def __init__(self, asn1_extKeyUsage):
        usageOIDs = set(
            [tuple_to_OID(usageOID) for usageOID in asn1_extKeyUsage])

        for (oid, attr) in ExtendedKeyUsageExt._keyPurposeAttrs.items():
            setattr(self, attr, oid in usageOIDs)