def test_oid_dotted_decimal(self): self.assertEqual(nss.oid_dotted_decimal(nss.SEC_OID_AVA_COMMON_NAME), 'OID.2.5.4.3') self.assertEqual(nss.oid_tag('OID.2.5.4.3'), nss.SEC_OID_AVA_COMMON_NAME) self.assertEqual(nss.oid_tag('2.5.4.3'), nss.SEC_OID_AVA_COMMON_NAME) self.assertRaises(ValueError, nss.oid_tag, 'OID.99.99.99.99')
def get_extensions(csr, datatype=PEM): """ Given a CSR return OIDs of certificate extensions. The return value is a tuple of strings """ request = load_certificate_request(csr, datatype) return tuple(nss.oid_dotted_decimal(ext.oid_tag)[4:] for ext in request.extensions)
def get_extensions(csr, datatype=PEM): """ Given a CSR return OIDs of certificate extensions. The return value is a tuple of strings """ request = load_certificate_request(csr, datatype) return tuple( nss.oid_dotted_decimal(ext.oid_tag)[4:] for ext in request.extensions)
def test_oid(self): self.assertEqual(nss.oid_str('2.5.4.3'), 'X520 Common Name') self.assertEqual(nss.oid_str(nss.SEC_OID_AVA_COMMON_NAME), 'X520 Common Name') self.assertEqual(nss.oid_str('SEC_OID_AVA_COMMON_NAME'), 'X520 Common Name') self.assertEqual(nss.oid_str('AVA_COMMON_NAME'), 'X520 Common Name') self.assertEqual(nss.oid_str('cn'), 'X520 Common Name') self.assertEqual(nss.oid_tag_name('2.5.4.3'), 'SEC_OID_AVA_COMMON_NAME') self.assertEqual(nss.oid_tag_name(nss.SEC_OID_AVA_COMMON_NAME), 'SEC_OID_AVA_COMMON_NAME') self.assertEqual(nss.oid_tag_name('SEC_OID_AVA_COMMON_NAME'), 'SEC_OID_AVA_COMMON_NAME') self.assertEqual(nss.oid_tag_name('AVA_COMMON_NAME'), 'SEC_OID_AVA_COMMON_NAME') self.assertEqual(nss.oid_tag_name('cn'), 'SEC_OID_AVA_COMMON_NAME') self.assertEqual(nss.oid_dotted_decimal('2.5.4.3'), 'OID.2.5.4.3') self.assertEqual(nss.oid_dotted_decimal(nss.SEC_OID_AVA_COMMON_NAME), 'OID.2.5.4.3') self.assertEqual(nss.oid_dotted_decimal('SEC_OID_AVA_COMMON_NAME'), 'OID.2.5.4.3') self.assertEqual(nss.oid_dotted_decimal('AVA_COMMON_NAME'), 'OID.2.5.4.3') self.assertEqual(nss.oid_dotted_decimal('cn'), 'OID.2.5.4.3') self.assertEqual(nss.oid_tag('2.5.4.3'), nss.SEC_OID_AVA_COMMON_NAME) self.assertEqual(nss.oid_tag(nss.SEC_OID_AVA_COMMON_NAME), nss.SEC_OID_AVA_COMMON_NAME) self.assertEqual(nss.oid_tag('SEC_OID_AVA_COMMON_NAME'), nss.SEC_OID_AVA_COMMON_NAME) self.assertEqual(nss.oid_tag('AVA_COMMON_NAME'), nss.SEC_OID_AVA_COMMON_NAME) self.assertEqual(nss.oid_tag('cn'), nss.SEC_OID_AVA_COMMON_NAME)
def get_prefixed_oid_str(ext): """Returns a string like 'OID.1.2...'.""" if ext.oid_tag == 0: return repr(ext) else: return nss.oid_dotted_decimal(ext.oid)