crypto — Generic cryptographic module¶
Note
pyca/cryptography is likely a better choice than using this module.
It contains a complete set of cryptographic primitives as well as a significantly better and more powerful X509 API.
If necessary you can convert to and from cryptography objects using the to_cryptography and from_cryptography methods on X509, X509Req, CRL, and PKey.
Elliptic curves¶
-
OpenSSL.crypto.get_elliptic_curves()¶ Return a set of objects representing the elliptic curves supported in the OpenSSL build in use.
The curve objects have a
unicodenameattribute by which they identify themselves.The curve objects are useful as values for the argument accepted by
Context.set_tmp_ecdh()to specify which elliptical curve should be used for ECDHE key exchange.
-
OpenSSL.crypto.get_elliptic_curve(name)¶ Return a single curve object selected by name.
See
get_elliptic_curves()for information about curve objects.If the named curve is not supported then
ValueErroris raised.
Serialization and deserialization¶
The following serialization functions take one of these constants to determine the format.
-
OpenSSL.crypto.FILETYPE_PEM¶
FILETYPE_PEM serializes data to a Base64-encoded encoded representation of the underlying ASN.1 data structure. This representation includes delimiters that define what data structure is contained within the Base64-encoded block: for example, for a certificate, the delimiters are -----BEGIN CERTIFICATE----- and -----END CERTIFICATE-----.
-
OpenSSL.crypto.FILETYPE_ASN1¶
FILETYPE_ASN1 serializes data to the underlying ASN.1 data structure. The format used by FILETYPE_ASN1 is also sometimes referred to as DER.
Certificates¶
-
OpenSSL.crypto.dump_certificate(type, cert)¶ Dump the certificate cert into a buffer string encoded with the type type.
-
OpenSSL.crypto.load_certificate(type, buffer)¶ Load a certificate (X509) from the string buffer encoded with the type type.
Certificate signing requests¶
-
OpenSSL.crypto.dump_certificate_request(type, req)¶ Dump the certificate request req into a buffer string encoded with the type type.
-
OpenSSL.crypto.load_certificate_request(type, buffer)¶ Load a certificate request (X509Req) from the string buffer encoded with the type type.
Private keys¶
-
OpenSSL.crypto.dump_privatekey(type, pkey, cipher=None, passphrase=None)¶ Dump the private key pkey into a buffer string encoded with the type type. Optionally (if type is
FILETYPE_PEM) encrypting it using cipher and passphrase.Parameters: - type – The file type (one of
FILETYPE_PEM,FILETYPE_ASN1, orFILETYPE_TEXT) - pkey (PKey) – The PKey to dump
- cipher – (optional) if encrypted PEM format, the cipher to use
- passphrase – (optional) if encrypted PEM format, this can be either the passphrase to use, or a callback for providing the passphrase.
Returns: The buffer with the dumped key in
Return type: bytes
- type – The file type (one of
-
OpenSSL.crypto.load_privatekey(type, buffer[, passphrase])¶ Load a private key (PKey) from the string buffer encoded with the type type (must be one of
FILETYPE_PEMandFILETYPE_ASN1).passphrase must be either a string or a callback for providing the pass phrase.
Public keys¶
-
OpenSSL.crypto.dump_publickey(type, pkey)¶ Dump a public key to a buffer.
Parameters: - type – The file type (one of
FILETYPE_PEMorFILETYPE_ASN1). - pkey (PKey) – The public key to dump
Returns: The buffer with the dumped key in it.
Return type: bytes
- type – The file type (one of
-
OpenSSL.crypto.load_publickey(type, buffer)¶ Load a public key from a buffer.
Parameters: - type – The file type (one of
FILETYPE_PEM,FILETYPE_ASN1). - buffer (A Python string object, either unicode or bytestring.) – The buffer the key is stored in.
Returns: The PKey object.
Return type: - type – The file type (one of
Certificate revocation lists¶
-
OpenSSL.crypto.dump_crl(type, crl)¶ Dump a certificate revocation list to a buffer.
Parameters: - type – The file type (one of
FILETYPE_PEM,FILETYPE_ASN1, orFILETYPE_TEXT). - crl (CRL) – The CRL to dump.
Returns: The buffer with the CRL.
Return type: bytes
- type – The file type (one of
-
OpenSSL.crypto.load_crl(type, buffer)¶ Load Certificate Revocation List (CRL) data from a string buffer. buffer encoded with the type type. The type type must either
FILETYPE_PEMorFILETYPE_ASN1).
-
OpenSSL.crypto.load_pkcs7_data(type, buffer)¶ Load pkcs7 data from the string buffer encoded with the type type. The type type must either
FILETYPE_PEMorFILETYPE_ASN1).
-
OpenSSL.crypto.load_pkcs12(buffer[, passphrase])¶ Load pkcs12 data from the string buffer. If the pkcs12 structure is encrypted, a passphrase must be included. The MAC is always checked and thus required.
See also the man page for the C function
PKCS12_parse().
Signing and verifying signatures¶
-
OpenSSL.crypto.sign(key, data, digest)¶ Sign a data string using the given key and message digest.
key is a
PKeyinstance. data is astrinstance. digest is astrnaming a supported message digest type, for exampleb"sha256".New in version 0.11.
-
OpenSSL.crypto.verify(certificate, signature, data, digest)¶ Verify the signature for a data string.
certificate is a
X509instance corresponding to the private key which generated the signature. signature is a str instance giving the signature itself. data is a str instance giving the data to which the signature applies. digest is a str instance naming the message digest type of the signature, for exampleb"sha256".New in version 0.11.
X509 objects¶
-
class
OpenSSL.crypto.X509¶ An X.509 certificate.
-
add_extensions(extensions)¶ Add extensions to the certificate.
Parameters: extensions (An iterable of X509Extensionobjects.) – The extensions to add.Returns: None
-
digest(digest_name)¶ Return the digest of the X509 object.
Parameters: digest_name ( bytes) – The name of the digest algorithm to use.Returns: The digest of the object, formatted as b":"-delimited hex pairs.Return type: bytes
-
classmethod
from_cryptography(crypto_cert)¶ Construct based on a
cryptographycrypto_cert.Parameters: crypto_key ( cryptography.x509.Certificate) – AcryptographyX.509 certificate.Return type: PKey New in version 17.1.0.
-
get_extension(index)¶ Get a specific extension of the certificate by index.
Extensions on a certificate are kept in order. The index parameter selects which extension will be returned.
Parameters: index (int) – The index of the extension to retrieve. Returns: The extension at the specified index. Return type: X509ExtensionRaises: IndexError – If the extension index was out of bounds. New in version 0.12.
-
get_extension_count()¶ Get the number of extensions on this certificate.
Returns: The number of extensions. Return type: intNew in version 0.12.
-
get_issuer()¶ Return the issuer of this certificate.
This creates a new
X509Namethat wraps the underlying issuer name field on the certificate. Modifying it will modify the underlying certificate, and will have the effect of modifying any otherX509Namethat refers to this issuer.Returns: The issuer of this certificate. Return type: X509Name
-
get_notAfter()¶ Get the timestamp at which the certificate stops being valid.
The timestamp is formatted as an ASN.1 TIME:
YYYYMMDDhhmmssZReturns: A timestamp string, or Noneif there is none.Return type: bytes or NoneType
-
get_notBefore()¶ Get the timestamp at which the certificate starts being valid.
The timestamp is formatted as an ASN.1 TIME:
YYYYMMDDhhmmssZReturns: A timestamp string, or Noneif there is none.Return type: bytes or NoneType
-
get_serial_number()¶ Return the serial number of this certificate.
Returns: The serial number. Return type: int
-
get_signature_algorithm()¶ Return the signature algorithm used in the certificate.
Returns: The name of the algorithm. Return type: bytesRaises: ValueError – If the signature algorithm is undefined. New in version 0.13.
-
get_subject()¶ Return the subject of this certificate.
This creates a new
X509Namethat wraps the underlying subject name field on the certificate. Modifying it will modify the underlying certificate, and will have the effect of modifying any otherX509Namethat refers to this subject.Returns: The subject of this certificate. Return type: X509Name
-
get_version()¶ Return the version number of the certificate.
Returns: The version number of the certificate. Return type: int
-
gmtime_adj_notAfter(amount)¶ Adjust the time stamp on which the certificate stops being valid.
Parameters: amount (int) – The number of seconds by which to adjust the timestamp. Returns: None
-
gmtime_adj_notBefore(amount)¶ Adjust the timestamp on which the certificate starts being valid.
Parameters: amount – The number of seconds by which to adjust the timestamp. Returns: None
-
has_expired()¶ Check whether the certificate has expired.
Returns: Trueif the certificate has expired,Falseotherwise.Return type: bool
-
set_issuer(issuer)¶ Set the issuer of this certificate.
Parameters: issuer ( X509Name) – The issuer.Returns: None
-
set_notAfter(when)¶ Set the timestamp at which the certificate stops being valid.
The timestamp is formatted as an ASN.1 TIME:
YYYYMMDDhhmmssZParameters: when (bytes) – A timestamp string. Returns: None
-
set_notBefore(when)¶ Set the timestamp at which the certificate starts being valid.
The timestamp is formatted as an ASN.1 TIME:
YYYYMMDDhhmmssZParameters: when (bytes) – A timestamp string. Returns: None
-
set_pubkey(pkey)¶ Set the public key of the certificate.
Parameters: pkey ( PKey) – The public key.Returns: None
-
set_serial_number(serial)¶ Set the serial number of the certificate.
Parameters: serial ( int) – The new serial number.Returns: :py:data`None`
-
set_subject(subject)¶ Set the subject of this certificate.
Parameters: subject ( X509Name) – The subject.Returns: None
-
set_version(version)¶ Set the version number of the certificate.
Parameters: version ( int) – The version number of the certificate.Returns: None
-
sign(pkey, digest)¶ Sign the certificate with this key and digest type.
Parameters: - pkey (
PKey) – The key to sign with. - digest (
bytes) – The name of the message digest to use.
Returns: None- pkey (
-
subject_name_hash()¶ Return the hash of the X509 subject.
Returns: The hash of the subject. Return type: bytes
-
to_cryptography()¶ Export as a
cryptographycertificate.Return type: cryptography.x509.CertificateNew in version 17.1.0.
-
X509Name objects¶
-
class
OpenSSL.crypto.X509Name(name)¶ An X.509 Distinguished Name.
Variables: - countryName – The country of the entity.
- C – Alias for
countryName. - stateOrProvinceName – The state or province of the entity.
- ST – Alias for
stateOrProvinceName. - localityName – The locality of the entity.
- L – Alias for
localityName. - organizationName – The organization name of the entity.
- O – Alias for
organizationName. - organizationalUnitName – The organizational unit of the entity.
- OU – Alias for
organizationalUnitName - commonName – The common name of the entity.
- CN – Alias for
commonName. - emailAddress – The e-mail address of the entity.
-
__init__(name)¶ Create a new X509Name, copying the given X509Name instance.
Parameters: name ( X509Name) – The name to copy.
-
der()¶ Return the DER encoding of this name.
Returns: The DER encoded form of this name. Return type: bytes
-
get_components()¶ Returns the components of this name, as a sequence of 2-tuples.
Returns: The components of this name. Return type: listofname, valuetuples.
-
hash()¶ Return an integer representation of the first four bytes of the MD5 digest of the DER representation of the name.
This is the Python equivalent of OpenSSL’s
X509_NAME_hash.Returns: The (integer) hash of this name. Return type: int
X509Req objects¶
-
class
OpenSSL.crypto.X509Req¶ An X.509 certificate signing requests.
-
add_extensions(extensions)¶ Add extensions to the certificate signing request.
Parameters: extensions (iterable of X509Extension) – The X.509 extensions to add.Returns: None
-
classmethod
from_cryptography(crypto_req)¶ Construct based on a
cryptographycrypto_req.Parameters: crypto_req ( cryptography.x509.CertificateSigningRequest) – AcryptographyX.509 certificate signing requestReturn type: PKey New in version 17.1.0.
-
get_extensions()¶ Get X.509 extensions in the certificate signing request.
Returns: The X.509 extensions in this request. Return type: listofX509Extensionobjects.New in version 0.15.
-
get_pubkey()¶ Get the public key of the certificate signing request.
Returns: The public key. Return type: PKey
-
get_subject()¶ Return the subject of this certificate signing request.
This creates a new
X509Namethat wraps the underlying subject name field on the certificate signing request. Modifying it will modify the underlying signing request, and will have the effect of modifying any otherX509Namethat refers to this subject.Returns: The subject of this certificate signing request. Return type: X509Name
-
get_version()¶ Get the version subfield (RFC 2459, section 4.1.2.1) of the certificate request.
Returns: The value of the version subfield. Return type: int
-
set_pubkey(pkey)¶ Set the public key of the certificate signing request.
Parameters: pkey ( PKey) – The public key to use.Returns: None
-
set_version(version)¶ Set the version subfield (RFC 2459, section 4.1.2.1) of the certificate request.
Parameters: version (int) – The version number. Returns: None
-
sign(pkey, digest)¶ Sign the certificate signing request with this key and digest type.
Parameters: - pkey (
PKey) – The key pair to sign with. - digest (
bytes) – The name of the message digest to use for the signature, e.g.b"sha256".
Returns: None- pkey (
-
to_cryptography()¶ Export as a
cryptographycertificate signing request.Return type: cryptography.x509.CertificateSigningRequestNew in version 17.1.0.
-
verify(pkey)¶ Verifies the signature on this certificate signing request.
Parameters: key (PKey) – A public key. Returns: Trueif the signature is correct.Return type: bool Raises: OpenSSL.crypto.Error – If the signature is invalid or there is a problem verifying the signature.
-
X509Store objects¶
-
class
OpenSSL.crypto.X509Store¶ An X.509 store.
An X.509 store is used to describe a context in which to verify a certificate. A description of a context may include a set of certificates to trust, a set of certificate revocation lists, verification flags and more.
An X.509 store, being only a description, cannot be used by itself to verify a certificate. To carry out the actual verification process, see
X509StoreContext.-
add_cert(cert)¶ Adds a trusted certificate to this store.
Adding a certificate with this method adds this certificate as a trusted certificate.
Parameters: cert (X509) – The certificate to add to this store.
Raises: - TypeError – If the certificate is not an
X509. - OpenSSL.crypto.Error – If OpenSSL was unhappy with your certificate.
Returns: Noneif the certificate was added successfully.- TypeError – If the certificate is not an
-
add_crl(crl)¶ Add a certificate revocation list to this store.
The certificate revocation lists added to a store will only be used if the associated flags are configured to check certificate revocation lists.
New in version 16.1.0.
Parameters: crl (CRL) – The certificate revocation list to add to this store. Returns: Noneif the certificate revocation list was added successfully.
-
set_flags(flags)¶ Set verification flags to this store.
Verification flags can be combined by oring them together.
Note
Setting a verification flag sometimes requires clients to add additional information to the store, otherwise a suitable error will be raised.
For example, in setting flags to enable CRL checking a suitable CRL must be added to the store otherwise an error will be raised.
New in version 16.1.0.
Parameters: flags (int) – The verification flags to set on this store. See X509StoreFlagsfor available constants.Returns: Noneif the verification flags were successfully set.
-
set_time(vfy_time)¶ Set the time against which the certificates are verified.
Normally the current time is used.
Note
For example, you can determine if a certificate was valid at a given time.
New in version 17.0.0.
Parameters: vfy_time (datetime) – The verification time to set on this store. Returns: Noneif the verification time was successfully set.
-
X509StoreContextError objects¶
-
class
OpenSSL.crypto.X509StoreContextError(message, certificate)¶ An exception raised when an error occurred while verifying a certificate using OpenSSL.X509StoreContext.verify_certificate.
Variables: certificate – The certificate which caused verificate failure.
X509StoreContext objects¶
-
class
OpenSSL.crypto.X509StoreContext(store, certificate)¶ An X.509 store context.
An X.509 store context is used to carry out the actual verification process of a certificate in a described context. For describing such a context, see
X509Store.Variables: - _store_ctx – The underlying X509_STORE_CTX structure used by this instance. It is dynamically allocated and automatically garbage collected.
- _store – See the
store__init__parameter. - _cert – See the
certificate__init__parameter.
Parameters: -
set_store(store)¶ Set the context’s X.509 store.
New in version 0.15.
Parameters: store (X509Store) – The store description which will be used for the purposes of any future verifications.
-
verify_certificate()¶ Verify a certificate in a context.
New in version 0.15.
Raises: X509StoreContextError – If an error occurred when validating a certificate in the context. Sets certificateattribute to indicate which certificate caused the error.
X509StoreFlags constants¶
-
class
OpenSSL.crypto.X509StoreFlags¶ Flags for X509 verification, used to change the behavior of
X509Store.See OpenSSL Verification Flags for details.
-
CRL_CHECK¶
-
CRL_CHECK_ALL¶
-
IGNORE_CRITICAL¶
-
X509_STRICT¶
-
ALLOW_PROXY_CERTS¶
-
POLICY_CHECK¶
-
EXPLICIT_POLICY¶
-
INHIBIT_MAP¶
-
NOTIFY_POLICY¶
-
CHECK_SS_SIGNATURE¶
-
CB_ISSUER_CHECK¶
-
PKey objects¶
-
class
OpenSSL.crypto.PKey¶ A class representing an DSA or RSA public key or key pair.
-
bits()¶ Returns the number of bits of the key
Returns: The number of bits of the key.
-
check()¶ Check the consistency of an RSA private key.
This is the Python equivalent of OpenSSL’s
RSA_check_key.Returns: Trueif key is consistent.Raises: - OpenSSL.crypto.Error – if the key is inconsistent.
- TypeError – if the key is of a type which cannot be checked. Only RSA keys can currently be checked.
-
classmethod
from_cryptography_key(crypto_key)¶ Construct based on a
cryptographycrypto_key.Parameters: crypto_key (One of cryptography’s key interfaces.) – Acryptographykey.Return type: PKey New in version 16.1.0.
-
generate_key(type, bits)¶ Generate a key pair of the given type, with the given number of bits.
This generates a key “into” the this object.
Parameters: Raises: Returns: None
-
to_cryptography_key()¶ Export as a
cryptographykey.Return type: One of cryptography’s key interfaces.New in version 16.1.0.
-
type()¶ Returns the type of the key
Returns: The type of the key.
-
PKCS7 objects¶
PKCS7 objects have the following methods:
-
PKCS7.type_is_signed()¶ FIXME
-
PKCS7.type_is_enveloped()¶ FIXME
-
PKCS7.type_is_signedAndEnveloped()¶ FIXME
-
PKCS7.type_is_data()¶ FIXME
-
PKCS7.get_type_name()¶ Get the type name of the PKCS7.
PKCS12 objects¶
-
class
OpenSSL.crypto.PKCS12¶ A PKCS #12 archive.
-
export(passphrase=None, iter=2048, maciter=1)¶ Dump a PKCS12 object as a string.
For more information, see the
PKCS12_create()man page.Parameters: - passphrase (
bytes) – The passphrase used to encrypt the structure. Unlike some other passphrase arguments, this must be a string, not a callback. - iter (
int) – Number of times to repeat the encryption step. - maciter (
int) – Number of times to repeat the MAC step.
Returns: The string representation of the PKCS #12 structure.
Return type: - passphrase (
-
get_ca_certificates()¶ Get the CA certificates in the PKCS #12 structure.
Returns: A tuple with the CA certificates in the chain, or Noneif there are none.Return type: tupleofX509orNone
-
get_certificate()¶ Get the certificate in the PKCS #12 structure.
Returns: The certificate, or Noneif there is none.Return type: X509orNone
-
get_friendlyname()¶ Get the friendly name in the PKCS# 12 structure.
Returns: The friendly name, or Noneif there is none.Return type: bytesorNone
-
get_privatekey()¶ Get the private key in the PKCS #12 structure.
Returns: The private key, or Noneif there is none.Return type: PKey
-
set_ca_certificates(cacerts)¶ Replace or set the CA certificates within the PKCS12 object.
Parameters: cacerts (An iterable of X509orNone) – The new CA certificates, orNoneto unset them.Returns: None
-
set_certificate(cert)¶ Set the certificate in the PKCS #12 structure.
Parameters: cert ( X509orNone) – The new certificate, orNoneto unset it.Returns: None
-
set_friendlyname(name)¶ Set the friendly name in the PKCS #12 structure.
Parameters: name ( bytesorNone) – The new friendly name, orNoneto unset.Returns: None
-
X509Extension objects¶
-
class
OpenSSL.crypto.X509Extension(type_name, critical, value, subject=None, issuer=None)¶ An X.509 v3 certificate extension.
-
__init__(type_name, critical, value, subject=None, issuer=None)¶ Initializes an X509 extension.
Parameters: - type_name (
bytes) – The name of the type of extension to create. - critical (bool) – A flag indicating whether this is a critical extension.
- value (
bytes) – The value of the extension. - subject (
X509) – Optional X509 certificate to use as subject. - issuer (
X509) – Optional X509 certificate to use as issuer.
- type_name (
-
__str__()¶ Returns: a nice text representation of the extension
-
get_critical()¶ Returns the critical field of this X.509 extension.
Returns: The critical field.
-
get_data()¶ Returns the data of the X509 extension, encoded as ASN.1.
Returns: The ASN.1 encoded data of this X509 extension. Return type: bytesNew in version 0.12.
-
get_short_name()¶ Returns the short type name of this X.509 extension.
The result is a byte string such as
b"basicConstraints".Returns: The short type name. Return type: bytesNew in version 0.12.
-
NetscapeSPKI objects¶
-
class
OpenSSL.crypto.NetscapeSPKI¶ A Netscape SPKI object.
-
b64_encode()¶ Generate a base64 encoded representation of this SPKI object.
Returns: The base64 encoded string. Return type: bytes
-
set_pubkey(pkey)¶ Set the public key of the certificate
Parameters: pkey – The public key Returns: None
-
sign(pkey, digest)¶ Sign the certificate request with this key and digest type.
Parameters: - pkey (
PKey) – The private key to sign with. - digest (
bytes) – The message digest to use.
Returns: None- pkey (
-
verify(key)¶ Verifies a signature on a certificate request.
Parameters: key (PKey) – The public key that signature is supposedly from. Returns: Trueif the signature is correct.Return type: bool Raises: OpenSSL.crypto.Error – If the signature is invalid, or there was a problem verifying the signature.
-
CRL objects¶
-
class
OpenSSL.crypto.CRL¶ A certificate revocation list.
-
add_revoked(revoked)¶ Add a revoked (by value not reference) to the CRL structure
This revocation will be added by value, not by reference. That means it’s okay to mutate it after adding: it won’t affect this CRL.
Parameters: revoked (Revoked) – The new revocation. Returns: None
-
export(cert, key, type=1, days=100, digest=<object object>)¶ Export the CRL as a string.
Parameters: - cert (X509) – The certificate used to sign the CRL.
- key (PKey) – The key used to sign the CRL.
- type (int) – The export format, either
FILETYPE_PEM,FILETYPE_ASN1, orFILETYPE_TEXT. - days (int) – The number of days until the next update of this CRL.
- digest (bytes) – The name of the message digest to use (eg
b"sha2566").
Return type: bytes
-
classmethod
from_cryptography(crypto_crl)¶ Construct based on a
cryptographycrypto_crl.Parameters: crypto_crl ( cryptography.x509.CertificateRevocationList) – Acryptographycertificate revocation listReturn type: CRL New in version 17.1.0.
-
get_revoked()¶ Return the revocations in this certificate revocation list.
These revocations will be provided by value, not by reference. That means it’s okay to mutate them: it won’t affect this CRL.
Returns: The revocations in this CRL. Return type: tupleofRevocation
-
set_lastUpdate(when)¶ Set when the CRL was last updated.
The timestamp is formatted as an ASN.1 TIME:
YYYYMMDDhhmmssZNew in version 16.1.0.
Parameters: when (bytes) – A timestamp string. Returns: None
-
set_nextUpdate(when)¶ Set when the CRL will next be udpated.
The timestamp is formatted as an ASN.1 TIME:
YYYYMMDDhhmmssZNew in version 16.1.0.
Parameters: when (bytes) – A timestamp string. Returns: None
-
set_version(version)¶ Set the CRL version.
New in version 16.1.0.
Parameters: version (int) – The version of the CRL. Returns: None
-
sign(issuer_cert, issuer_key, digest)¶ Sign the CRL.
Signing a CRL enables clients to associate the CRL itself with an issuer. Before a CRL is meaningful to other OpenSSL functions, it must be signed by an issuer.
This method implicitly sets the issuer’s name based on the issuer certificate and private key used to sign the CRL.
New in version 16.1.0.
Parameters:
-
to_cryptography()¶ Export as a
cryptographyCRL.Return type: cryptography.x509.CertificateRevocationListNew in version 17.1.0.
-
Revoked objects¶
-
class
OpenSSL.crypto.Revoked¶ A certificate revocation.
-
all_reasons()¶ Return a list of all the supported reason strings.
This list is a copy; modifying it does not change the supported reason strings.
Returns: A list of reason strings. Return type: listofbytes
-
get_reason()¶ Get the reason of this revocation.
Returns: The reason, or Noneif there is none.Return type: bytes or NoneType See also
all_reasons(), which gives you a list of all supported reasons this method might return.
-
get_rev_date()¶ Get the revocation timestamp.
Returns: The timestamp of the revocation, as ASN.1 TIME. Return type: bytes
-
get_serial()¶ Get the serial number.
The serial number is formatted as a hexadecimal number encoded in ASCII.
Returns: The serial number. Return type: bytes
-
set_reason(reason)¶ Set the reason of this revocation.
If
reasonisNone, delete the reason instead.Parameters: reason ( bytesorNoneType) – The reason string.Returns: NoneSee also
all_reasons(), which gives you a list of all supported reasons which you might pass to this method.
-
set_rev_date(when)¶ Set the revocation timestamp.
Parameters: when (bytes) – The timestamp of the revocation, as ASN.1 TIME. Returns: None
-
set_serial(hex_str)¶ Set the serial number.
The serial number is formatted as a hexadecimal number encoded in ASCII.
Parameters: hex_str (bytes) – The new serial number. Returns: None
-
Digest names¶
Several of the functions and methods in this module take a digest name.
These must be strings describing a digest algorithm supported by OpenSSL (by EVP_get_digestbyname, specifically).
For example, b"sha256" or b"sha384".
More information and a list of these digest names can be found in the EVP_DigestInit(3) man page of your OpenSSL installation.
This page can be found online for the latest version of OpenSSL:
https://www.openssl.org/docs/manmaster/man3/EVP_DigestInit.html