__init__.py 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. # This file is dual licensed under the terms of the Apache License, Version
  2. # 2.0, and the BSD License. See the LICENSE file in the root of this repository
  3. # for complete details.
  4. from cryptography.x509 import certificate_transparency
  5. from cryptography.x509.base import (
  6. AttributeNotFound,
  7. Certificate,
  8. CertificateBuilder,
  9. CertificateRevocationList,
  10. CertificateRevocationListBuilder,
  11. CertificateSigningRequest,
  12. CertificateSigningRequestBuilder,
  13. InvalidVersion,
  14. RevokedCertificate,
  15. RevokedCertificateBuilder,
  16. Version,
  17. load_der_x509_certificate,
  18. load_der_x509_crl,
  19. load_der_x509_csr,
  20. load_pem_x509_certificate,
  21. load_pem_x509_crl,
  22. load_pem_x509_csr,
  23. random_serial_number,
  24. )
  25. from cryptography.x509.extensions import (
  26. AccessDescription,
  27. AuthorityInformationAccess,
  28. AuthorityKeyIdentifier,
  29. BasicConstraints,
  30. CRLDistributionPoints,
  31. CRLNumber,
  32. CRLReason,
  33. CertificateIssuer,
  34. CertificatePolicies,
  35. DeltaCRLIndicator,
  36. DistributionPoint,
  37. DuplicateExtension,
  38. ExtendedKeyUsage,
  39. Extension,
  40. ExtensionNotFound,
  41. ExtensionType,
  42. Extensions,
  43. FreshestCRL,
  44. GeneralNames,
  45. InhibitAnyPolicy,
  46. InvalidityDate,
  47. IssuerAlternativeName,
  48. IssuingDistributionPoint,
  49. KeyUsage,
  50. NameConstraints,
  51. NoticeReference,
  52. OCSPNoCheck,
  53. OCSPNonce,
  54. PolicyConstraints,
  55. PolicyInformation,
  56. PrecertPoison,
  57. PrecertificateSignedCertificateTimestamps,
  58. ReasonFlags,
  59. SignedCertificateTimestamps,
  60. SubjectAlternativeName,
  61. SubjectInformationAccess,
  62. SubjectKeyIdentifier,
  63. TLSFeature,
  64. TLSFeatureType,
  65. UnrecognizedExtension,
  66. UserNotice,
  67. )
  68. from cryptography.x509.general_name import (
  69. DNSName,
  70. DirectoryName,
  71. GeneralName,
  72. IPAddress,
  73. OtherName,
  74. RFC822Name,
  75. RegisteredID,
  76. UniformResourceIdentifier,
  77. UnsupportedGeneralNameType,
  78. )
  79. from cryptography.x509.name import (
  80. Name,
  81. NameAttribute,
  82. RelativeDistinguishedName,
  83. )
  84. from cryptography.x509.oid import (
  85. AuthorityInformationAccessOID,
  86. CRLEntryExtensionOID,
  87. CertificatePoliciesOID,
  88. ExtendedKeyUsageOID,
  89. ExtensionOID,
  90. NameOID,
  91. ObjectIdentifier,
  92. SignatureAlgorithmOID,
  93. )
  94. OID_AUTHORITY_INFORMATION_ACCESS = ExtensionOID.AUTHORITY_INFORMATION_ACCESS
  95. OID_AUTHORITY_KEY_IDENTIFIER = ExtensionOID.AUTHORITY_KEY_IDENTIFIER
  96. OID_BASIC_CONSTRAINTS = ExtensionOID.BASIC_CONSTRAINTS
  97. OID_CERTIFICATE_POLICIES = ExtensionOID.CERTIFICATE_POLICIES
  98. OID_CRL_DISTRIBUTION_POINTS = ExtensionOID.CRL_DISTRIBUTION_POINTS
  99. OID_EXTENDED_KEY_USAGE = ExtensionOID.EXTENDED_KEY_USAGE
  100. OID_FRESHEST_CRL = ExtensionOID.FRESHEST_CRL
  101. OID_INHIBIT_ANY_POLICY = ExtensionOID.INHIBIT_ANY_POLICY
  102. OID_ISSUER_ALTERNATIVE_NAME = ExtensionOID.ISSUER_ALTERNATIVE_NAME
  103. OID_KEY_USAGE = ExtensionOID.KEY_USAGE
  104. OID_NAME_CONSTRAINTS = ExtensionOID.NAME_CONSTRAINTS
  105. OID_OCSP_NO_CHECK = ExtensionOID.OCSP_NO_CHECK
  106. OID_POLICY_CONSTRAINTS = ExtensionOID.POLICY_CONSTRAINTS
  107. OID_POLICY_MAPPINGS = ExtensionOID.POLICY_MAPPINGS
  108. OID_SUBJECT_ALTERNATIVE_NAME = ExtensionOID.SUBJECT_ALTERNATIVE_NAME
  109. OID_SUBJECT_DIRECTORY_ATTRIBUTES = ExtensionOID.SUBJECT_DIRECTORY_ATTRIBUTES
  110. OID_SUBJECT_INFORMATION_ACCESS = ExtensionOID.SUBJECT_INFORMATION_ACCESS
  111. OID_SUBJECT_KEY_IDENTIFIER = ExtensionOID.SUBJECT_KEY_IDENTIFIER
  112. OID_DSA_WITH_SHA1 = SignatureAlgorithmOID.DSA_WITH_SHA1
  113. OID_DSA_WITH_SHA224 = SignatureAlgorithmOID.DSA_WITH_SHA224
  114. OID_DSA_WITH_SHA256 = SignatureAlgorithmOID.DSA_WITH_SHA256
  115. OID_ECDSA_WITH_SHA1 = SignatureAlgorithmOID.ECDSA_WITH_SHA1
  116. OID_ECDSA_WITH_SHA224 = SignatureAlgorithmOID.ECDSA_WITH_SHA224
  117. OID_ECDSA_WITH_SHA256 = SignatureAlgorithmOID.ECDSA_WITH_SHA256
  118. OID_ECDSA_WITH_SHA384 = SignatureAlgorithmOID.ECDSA_WITH_SHA384
  119. OID_ECDSA_WITH_SHA512 = SignatureAlgorithmOID.ECDSA_WITH_SHA512
  120. OID_RSA_WITH_MD5 = SignatureAlgorithmOID.RSA_WITH_MD5
  121. OID_RSA_WITH_SHA1 = SignatureAlgorithmOID.RSA_WITH_SHA1
  122. OID_RSA_WITH_SHA224 = SignatureAlgorithmOID.RSA_WITH_SHA224
  123. OID_RSA_WITH_SHA256 = SignatureAlgorithmOID.RSA_WITH_SHA256
  124. OID_RSA_WITH_SHA384 = SignatureAlgorithmOID.RSA_WITH_SHA384
  125. OID_RSA_WITH_SHA512 = SignatureAlgorithmOID.RSA_WITH_SHA512
  126. OID_RSASSA_PSS = SignatureAlgorithmOID.RSASSA_PSS
  127. OID_COMMON_NAME = NameOID.COMMON_NAME
  128. OID_COUNTRY_NAME = NameOID.COUNTRY_NAME
  129. OID_DOMAIN_COMPONENT = NameOID.DOMAIN_COMPONENT
  130. OID_DN_QUALIFIER = NameOID.DN_QUALIFIER
  131. OID_EMAIL_ADDRESS = NameOID.EMAIL_ADDRESS
  132. OID_GENERATION_QUALIFIER = NameOID.GENERATION_QUALIFIER
  133. OID_GIVEN_NAME = NameOID.GIVEN_NAME
  134. OID_LOCALITY_NAME = NameOID.LOCALITY_NAME
  135. OID_ORGANIZATIONAL_UNIT_NAME = NameOID.ORGANIZATIONAL_UNIT_NAME
  136. OID_ORGANIZATION_NAME = NameOID.ORGANIZATION_NAME
  137. OID_PSEUDONYM = NameOID.PSEUDONYM
  138. OID_SERIAL_NUMBER = NameOID.SERIAL_NUMBER
  139. OID_STATE_OR_PROVINCE_NAME = NameOID.STATE_OR_PROVINCE_NAME
  140. OID_SURNAME = NameOID.SURNAME
  141. OID_TITLE = NameOID.TITLE
  142. OID_CLIENT_AUTH = ExtendedKeyUsageOID.CLIENT_AUTH
  143. OID_CODE_SIGNING = ExtendedKeyUsageOID.CODE_SIGNING
  144. OID_EMAIL_PROTECTION = ExtendedKeyUsageOID.EMAIL_PROTECTION
  145. OID_OCSP_SIGNING = ExtendedKeyUsageOID.OCSP_SIGNING
  146. OID_SERVER_AUTH = ExtendedKeyUsageOID.SERVER_AUTH
  147. OID_TIME_STAMPING = ExtendedKeyUsageOID.TIME_STAMPING
  148. OID_ANY_POLICY = CertificatePoliciesOID.ANY_POLICY
  149. OID_CPS_QUALIFIER = CertificatePoliciesOID.CPS_QUALIFIER
  150. OID_CPS_USER_NOTICE = CertificatePoliciesOID.CPS_USER_NOTICE
  151. OID_CERTIFICATE_ISSUER = CRLEntryExtensionOID.CERTIFICATE_ISSUER
  152. OID_CRL_REASON = CRLEntryExtensionOID.CRL_REASON
  153. OID_INVALIDITY_DATE = CRLEntryExtensionOID.INVALIDITY_DATE
  154. OID_CA_ISSUERS = AuthorityInformationAccessOID.CA_ISSUERS
  155. OID_OCSP = AuthorityInformationAccessOID.OCSP
  156. __all__ = [
  157. "certificate_transparency",
  158. "load_pem_x509_certificate",
  159. "load_der_x509_certificate",
  160. "load_pem_x509_csr",
  161. "load_der_x509_csr",
  162. "load_pem_x509_crl",
  163. "load_der_x509_crl",
  164. "random_serial_number",
  165. "AttributeNotFound",
  166. "InvalidVersion",
  167. "DeltaCRLIndicator",
  168. "DuplicateExtension",
  169. "ExtensionNotFound",
  170. "UnsupportedGeneralNameType",
  171. "NameAttribute",
  172. "Name",
  173. "RelativeDistinguishedName",
  174. "ObjectIdentifier",
  175. "ExtensionType",
  176. "Extensions",
  177. "Extension",
  178. "ExtendedKeyUsage",
  179. "FreshestCRL",
  180. "IssuingDistributionPoint",
  181. "TLSFeature",
  182. "TLSFeatureType",
  183. "OCSPNoCheck",
  184. "BasicConstraints",
  185. "CRLNumber",
  186. "KeyUsage",
  187. "AuthorityInformationAccess",
  188. "SubjectInformationAccess",
  189. "AccessDescription",
  190. "CertificatePolicies",
  191. "PolicyInformation",
  192. "UserNotice",
  193. "NoticeReference",
  194. "SubjectKeyIdentifier",
  195. "NameConstraints",
  196. "CRLDistributionPoints",
  197. "DistributionPoint",
  198. "ReasonFlags",
  199. "InhibitAnyPolicy",
  200. "SubjectAlternativeName",
  201. "IssuerAlternativeName",
  202. "AuthorityKeyIdentifier",
  203. "GeneralNames",
  204. "GeneralName",
  205. "RFC822Name",
  206. "DNSName",
  207. "UniformResourceIdentifier",
  208. "RegisteredID",
  209. "DirectoryName",
  210. "IPAddress",
  211. "OtherName",
  212. "Certificate",
  213. "CertificateRevocationList",
  214. "CertificateRevocationListBuilder",
  215. "CertificateSigningRequest",
  216. "RevokedCertificate",
  217. "RevokedCertificateBuilder",
  218. "CertificateSigningRequestBuilder",
  219. "CertificateBuilder",
  220. "Version",
  221. "OID_CA_ISSUERS",
  222. "OID_OCSP",
  223. "CertificateIssuer",
  224. "CRLReason",
  225. "InvalidityDate",
  226. "UnrecognizedExtension",
  227. "PolicyConstraints",
  228. "PrecertificateSignedCertificateTimestamps",
  229. "PrecertPoison",
  230. "OCSPNonce",
  231. "SignedCertificateTimestamps",
  232. "SignatureAlgorithmOID",
  233. "NameOID",
  234. ]