x509.pyi 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. import datetime
  5. import typing
  6. from cryptography import x509
  7. from cryptography.hazmat.primitives import hashes
  8. from cryptography.hazmat.primitives.asymmetric.padding import PSS, PKCS1v15
  9. from cryptography.hazmat.primitives.asymmetric.types import PrivateKeyTypes
  10. def load_pem_x509_certificate(
  11. data: bytes, backend: typing.Any = None
  12. ) -> x509.Certificate: ...
  13. def load_der_x509_certificate(
  14. data: bytes, backend: typing.Any = None
  15. ) -> x509.Certificate: ...
  16. def load_pem_x509_certificates(
  17. data: bytes,
  18. ) -> list[x509.Certificate]: ...
  19. def load_pem_x509_crl(
  20. data: bytes, backend: typing.Any = None
  21. ) -> x509.CertificateRevocationList: ...
  22. def load_der_x509_crl(
  23. data: bytes, backend: typing.Any = None
  24. ) -> x509.CertificateRevocationList: ...
  25. def load_pem_x509_csr(
  26. data: bytes, backend: typing.Any = None
  27. ) -> x509.CertificateSigningRequest: ...
  28. def load_der_x509_csr(
  29. data: bytes, backend: typing.Any = None
  30. ) -> x509.CertificateSigningRequest: ...
  31. def encode_name_bytes(name: x509.Name) -> bytes: ...
  32. def encode_extension_value(extension: x509.ExtensionType) -> bytes: ...
  33. def create_x509_certificate(
  34. builder: x509.CertificateBuilder,
  35. private_key: PrivateKeyTypes,
  36. hash_algorithm: hashes.HashAlgorithm | None,
  37. rsa_padding: PKCS1v15 | PSS | None,
  38. ) -> x509.Certificate: ...
  39. def create_x509_csr(
  40. builder: x509.CertificateSigningRequestBuilder,
  41. private_key: PrivateKeyTypes,
  42. hash_algorithm: hashes.HashAlgorithm | None,
  43. rsa_padding: PKCS1v15 | PSS | None,
  44. ) -> x509.CertificateSigningRequest: ...
  45. def create_x509_crl(
  46. builder: x509.CertificateRevocationListBuilder,
  47. private_key: PrivateKeyTypes,
  48. hash_algorithm: hashes.HashAlgorithm | None,
  49. rsa_padding: PKCS1v15 | PSS | None,
  50. ) -> x509.CertificateRevocationList: ...
  51. class Sct: ...
  52. class Certificate: ...
  53. class RevokedCertificate: ...
  54. class CertificateRevocationList: ...
  55. class CertificateSigningRequest: ...
  56. class PolicyBuilder:
  57. def time(self, new_time: datetime.datetime) -> PolicyBuilder: ...
  58. def store(self, new_store: Store) -> PolicyBuilder: ...
  59. def max_chain_depth(self, new_max_chain_depth: int) -> PolicyBuilder: ...
  60. def build_client_verifier(self) -> ClientVerifier: ...
  61. def build_server_verifier(
  62. self, subject: x509.verification.Subject
  63. ) -> ServerVerifier: ...
  64. class VerifiedClient:
  65. @property
  66. def subjects(self) -> list[x509.GeneralName]: ...
  67. @property
  68. def chain(self) -> list[x509.Certificate]: ...
  69. class ClientVerifier:
  70. @property
  71. def validation_time(self) -> datetime.datetime: ...
  72. @property
  73. def store(self) -> Store: ...
  74. @property
  75. def max_chain_depth(self) -> int: ...
  76. def verify(
  77. self,
  78. leaf: x509.Certificate,
  79. intermediates: list[x509.Certificate],
  80. ) -> VerifiedClient: ...
  81. class ServerVerifier:
  82. @property
  83. def subject(self) -> x509.verification.Subject: ...
  84. @property
  85. def validation_time(self) -> datetime.datetime: ...
  86. @property
  87. def store(self) -> Store: ...
  88. @property
  89. def max_chain_depth(self) -> int: ...
  90. def verify(
  91. self,
  92. leaf: x509.Certificate,
  93. intermediates: list[x509.Certificate],
  94. ) -> list[x509.Certificate]: ...
  95. class Store:
  96. def __init__(self, certs: list[x509.Certificate]) -> None: ...
  97. class VerificationError(Exception):
  98. pass