Skip to content

Commit 09fb854

Browse files
alexclaude
andauthored
Expose RevokedCertificate Rust class directly (#13837)
Fixes #11437 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7e99c4c commit 09fb854

File tree

2 files changed

+10
-38
lines changed

2 files changed

+10
-38
lines changed

src/cryptography/hazmat/bindings/_rust/x509.pyi

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,15 @@ class Certificate:
129129
def public_bytes(self, encoding: serialization.Encoding) -> bytes: ...
130130
def verify_directly_issued_by(self, issuer: Certificate) -> None: ...
131131

132-
class RevokedCertificate: ...
132+
class RevokedCertificate:
133+
@property
134+
def serial_number(self) -> int: ...
135+
@property
136+
def revocation_date(self) -> datetime.datetime: ...
137+
@property
138+
def revocation_date_utc(self) -> datetime.datetime: ...
139+
@property
140+
def extensions(self) -> x509.Extensions: ...
133141

134142
class CertificateRevocationList:
135143
def public_bytes(self, encoding: serialization.Encoding) -> bytes: ...

src/cryptography/x509/base.py

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from __future__ import annotations
66

7-
import abc
87
import datetime
98
import os
109
import typing
@@ -29,7 +28,6 @@
2928
)
3029
from cryptography.x509.extensions import (
3130
Extension,
32-
Extensions,
3331
ExtensionType,
3432
_make_sequence_methods,
3533
)
@@ -160,41 +158,7 @@ def __init__(self, msg: str, parsed_version: int) -> None:
160158

161159

162160
Certificate = rust_x509.Certificate
163-
164-
165-
class RevokedCertificate(metaclass=abc.ABCMeta):
166-
@property
167-
@abc.abstractmethod
168-
def serial_number(self) -> int:
169-
"""
170-
Returns the serial number of the revoked certificate.
171-
"""
172-
173-
@property
174-
@abc.abstractmethod
175-
def revocation_date(self) -> datetime.datetime:
176-
"""
177-
Returns the date of when this certificate was revoked.
178-
"""
179-
180-
@property
181-
@abc.abstractmethod
182-
def revocation_date_utc(self) -> datetime.datetime:
183-
"""
184-
Returns the date of when this certificate was revoked as a non-naive
185-
UTC datetime.
186-
"""
187-
188-
@property
189-
@abc.abstractmethod
190-
def extensions(self) -> Extensions:
191-
"""
192-
Returns an Extensions object containing a list of Revoked extensions.
193-
"""
194-
195-
196-
# Runtime isinstance checks need this since the rust class is not a subclass.
197-
RevokedCertificate.register(rust_x509.RevokedCertificate)
161+
RevokedCertificate = rust_x509.RevokedCertificate
198162

199163

200164
CertificateRevocationList = rust_x509.CertificateRevocationList

0 commit comments

Comments
 (0)