def build_unsuccessful(cls, response_status): from cryptography.hazmat.backends.openssl.backend import backend if not isinstance(response_status, OCSPResponseStatus): raise TypeError( "response_status must be an item from OCSPResponseStatus") if response_status is OCSPResponseStatus.SUCCESSFUL: raise ValueError("response_status cannot be SUCCESSFUL") return backend.create_ocsp_response(response_status, None, None, None)
def sign(self, private_key, algorithm): from cryptography.hazmat.backends.openssl.backend import backend if self._response is None: raise ValueError("You must add a response before signing") if self._responder_id is None: raise ValueError("You must add a responder_id before signing") return backend.create_ocsp_response(OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm)
def build_unsuccessful(cls, response_status): from cryptography.hazmat.backends.openssl.backend import backend if not isinstance(response_status, OCSPResponseStatus): raise TypeError( "response_status must be an item from OCSPResponseStatus" ) if response_status is OCSPResponseStatus.SUCCESSFUL: raise ValueError("response_status cannot be SUCCESSFUL") return backend.create_ocsp_response(response_status, None, None, None)
def sign(self, private_key, algorithm): from cryptography.hazmat.backends.openssl.backend import backend if self._response is None: raise ValueError("You must add a response before signing") if self._responder_id is None: raise ValueError("You must add a responder_id before signing") if not isinstance(algorithm, hashes.HashAlgorithm): raise TypeError("Algorithm must be a registered hash algorithm.") return backend.create_ocsp_response(OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm)
def sign(self, private_key, algorithm): from cryptography.hazmat.backends.openssl.backend import backend if self._response is None: raise ValueError("You must add a response before signing") if self._responder_id is None: raise ValueError("You must add a responder_id before signing") if not isinstance(algorithm, hashes.HashAlgorithm): raise TypeError("Algorithm must be a registered hash algorithm.") return backend.create_ocsp_response( OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm )
def sign( self, private_key: _PRIVATE_KEY_TYPES, algorithm: typing.Optional[hashes.HashAlgorithm], ) -> OCSPResponse: from cryptography.hazmat.backends.openssl.backend import backend if self._response is None: raise ValueError("You must add a response before signing") if self._responder_id is None: raise ValueError("You must add a responder_id before signing") return backend.create_ocsp_response(OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm)
def sign(self, private_key, algorithm): from cryptography.hazmat.backends.openssl.backend import backend if self._response is None: raise ValueError("You must add a response before signing") if self._responder_id is None: raise ValueError("You must add a responder_id before signing") if isinstance(private_key, (ed25519.Ed25519PrivateKey, ed448.Ed448PrivateKey)): if algorithm is not None: raise ValueError( "algorithm must be None when signing via ed25519 or ed448") elif not isinstance(algorithm, hashes.HashAlgorithm): raise TypeError("Algorithm must be a registered hash algorithm.") return backend.create_ocsp_response(OCSPResponseStatus.SUCCESSFUL, self, private_key, algorithm)