Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove OCSPSingleResponse abc #11993

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/cryptography/hazmat/bindings/_rust/ocsp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,31 @@ class OCSPResponse:
def single_extensions(self) -> x509.Extensions: ...
def public_bytes(self, encoding: serialization.Encoding) -> bytes: ...

class OCSPSingleResponse: ...
class OCSPSingleResponse:
@property
def certificate_status(self) -> ocsp.OCSPCertStatus: ...
@property
def revocation_time(self) -> datetime.datetime | None: ...
@property
def revocation_time_utc(self) -> datetime.datetime | None: ...
@property
def revocation_reason(self) -> x509.ReasonFlags | None: ...
@property
def this_update(self) -> datetime.datetime: ...
@property
def this_update_utc(self) -> datetime.datetime: ...
@property
def next_update(self) -> datetime.datetime | None: ...
@property
def next_update_utc(self) -> datetime.datetime | None: ...
@property
def issuer_key_hash(self) -> bytes: ...
@property
def issuer_name_hash(self) -> bytes: ...
@property
def hash_algorithm(self) -> hashes.HashAlgorithm: ...
@property
def serial_number(self) -> int: ...

def load_der_ocsp_request(data: bytes) -> ocsp.OCSPRequest: ...
def load_der_ocsp_response(data: bytes) -> ocsp.OCSPResponse: ...
Expand Down
96 changes: 1 addition & 95 deletions src/cryptography/x509/ocsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from __future__ import annotations

import abc
import datetime
import typing

Expand Down Expand Up @@ -127,102 +126,9 @@ def __init__(
self._revocation_reason = revocation_reason


class OCSPSingleResponse(metaclass=abc.ABCMeta):
@property
@abc.abstractmethod
def certificate_status(self) -> OCSPCertStatus:
"""
The status of the certificate (an element from the OCSPCertStatus enum)
"""

@property
@abc.abstractmethod
def revocation_time(self) -> datetime.datetime | None:
"""
The date of when the certificate was revoked or None if not
revoked.
"""

@property
@abc.abstractmethod
def revocation_time_utc(self) -> datetime.datetime | None:
"""
The date of when the certificate was revoked or None if not
revoked. Represented as a non-naive UTC datetime.
"""

@property
@abc.abstractmethod
def revocation_reason(self) -> x509.ReasonFlags | None:
"""
The reason the certificate was revoked or None if not specified or
not revoked.
"""

@property
@abc.abstractmethod
def this_update(self) -> datetime.datetime:
"""
The most recent time at which the status being indicated is known by
the responder to have been correct
"""

@property
@abc.abstractmethod
def this_update_utc(self) -> datetime.datetime:
"""
The most recent time at which the status being indicated is known by
the responder to have been correct. Represented as a non-naive UTC
datetime.
"""

@property
@abc.abstractmethod
def next_update(self) -> datetime.datetime | None:
"""
The time when newer information will be available
"""

@property
@abc.abstractmethod
def next_update_utc(self) -> datetime.datetime | None:
"""
The time when newer information will be available. Represented as a
non-naive UTC datetime.
"""

@property
@abc.abstractmethod
def issuer_key_hash(self) -> bytes:
"""
The hash of the issuer public key
"""

@property
@abc.abstractmethod
def issuer_name_hash(self) -> bytes:
"""
The hash of the issuer name
"""

@property
@abc.abstractmethod
def hash_algorithm(self) -> hashes.HashAlgorithm:
"""
The hash algorithm used in the issuer name and key hashes
"""

@property
@abc.abstractmethod
def serial_number(self) -> int:
"""
The serial number of the cert whose status is being checked
"""


OCSPRequest = ocsp.OCSPRequest
OCSPResponse = ocsp.OCSPResponse
OCSPSingleResponse.register(ocsp.OCSPSingleResponse)
OCSPSingleResponse = ocsp.OCSPSingleResponse


class OCSPRequestBuilder:
Expand Down