DN Attribute OIDs
synta.oids.attr provides OID constants for Distinguished Name (DN) attribute types.
import synta.oids.attr
Constants
All constants are ObjectIdentifier instances.
| Constant | OID | RFC 4514 label |
|---|---|---|
COMMON_NAME | 2.5.4.3 | CN |
ORGANIZATION | 2.5.4.10 | O |
ORG_UNIT | 2.5.4.11 | OU |
COUNTRY | 2.5.4.6 | C |
STATE | 2.5.4.8 | ST |
LOCALITY | 2.5.4.7 | L |
STREET | 2.5.4.9 | street |
SERIAL_NUMBER | 2.5.4.5 | serialNumber |
EMAIL_ADDRESS | 1.2.840.113549.1.9.1 | emailAddress |
GIVEN_NAME | 2.5.4.42 | givenName |
SURNAME | 2.5.4.4 | SN |
TITLE | 2.5.4.12 | title |
INITIALS | 2.5.4.43 | initials |
ORG_IDENTIFIER | 2.5.4.97 | organizationIdentifier |
USER_ID | 0.9.2342.19200300.100.1.1 | uid |
DOMAIN_COMPONENT | 0.9.2342.19200300.100.1.25 | dc |
Usage
import synta
import synta.oids.attr as attr
# Parse a certificate subject and look up specific attributes
cert = synta.Certificate.from_der(open("cert.der", "rb").read())
name_attrs = synta.parse_name_attrs(cert.subject_raw_der)
# name_attrs is a list of (dotted_oid_str, value_str) tuples
for oid_str, value in name_attrs:
if oid_str == str(attr.COMMON_NAME):
print(f"CN={value}")
elif oid_str == str(attr.ORGANIZATION):
print(f"O={value}")
elif oid_str == str(attr.COUNTRY):
print(f"C={value}")
# Use as hashable key
lookup = {attr.COMMON_NAME: "common name", attr.ORGANIZATION: "org"}
See also Well-known OIDs for the complete OID constant catalog.