From 3d385debe23d00a12c45c38183da062d932df923 Mon Sep 17 00:00:00 2001 From: Brad Warren Date: Thu, 4 Jun 2020 16:03:28 -0700 Subject: [PATCH] Implement _CryptographyOCSPResponse --- certbot/certbot/ocsp.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/certbot/certbot/ocsp.py b/certbot/certbot/ocsp.py index 75b59fdf6..dca0b8323 100644 --- a/certbot/certbot/ocsp.py +++ b/certbot/certbot/ocsp.py @@ -189,6 +189,47 @@ class RevocationChecker(object): class _CryptographyOCSPResponse(interfaces.OCSPResponse): """Cryptography implementation of OCSPResponse interface.""" + def __init__(self, ocsp_response): + """Initialize. + + :param ocsp.OCSPResponse ocsp_response: OCSP response + + """ + self._ocsp_response = ocsp_response + + @property + def certificate_status(self): + """Certificate status + + :rtype: OCSPCertStatus + + """ + status = self._ocsp_response.certificate_status + if status == ocsp.OCSPCertStatus.GOOD: + return interfaces.OCSPCertStatus.GOOD + elif status == ocsp.OCSPCertStatus.REVOKED: + return interfaces.OCSPCertStatus.REVOKED + else: # there is only one option left + return interfaces.OCSPCertStatus.UNKNOWN + + @property + def next_update(self): + """Next update + + :rtype: datetime.datetime + + """ + return self._ocsp_response.next_update + + @property + def bytes(self): + """Raw bytes of the OCSP response + + :rtype: bytes + + """ + return self._ocsp_response.public_bytes(serialization.Encoding.DER) + def _determine_ocsp_server(cert_path): # type: (str) -> Tuple[Optional[str], Optional[str]]