A class representing X.509 certificates.
A class representing X.509 Distinguished Names.
This constructor creates a copy of x509name which should be an instance of X509Name.
A class representing X.509 certificate requests.
A Python type object representing the X509Store object type.
A class representing DSA or RSA keys.
A Python type object representing the PKCS7 object type.
A Python type object representing the PKCS12 object type.
See X509Extension.
A class representing an X.509 v3 certificate extensions. See http://openssl.org/docs/apps/x509v3_config.html#STANDARD_EXTENSIONS for typename strings and their options. Optional parameters subject and issuer must be X509 objects.
See NetscapeSPKI.
A class representing Netscape SPKI objects.
If the enc argument is present, it should be a base64-encoded string representing a NetscapeSPKI object, as returned by the b64_encode() method.
A class representing Certifcate Revocation List objects.
A class representing Revocation objects of CRL.
Dump the certificate cert into a buffer string encoded with the type type.
Dump the certificate request req into a buffer string encoded with the type type.
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.
passphrase must be either a string or a callback for providing the pass phrase.
Load a certificate (X509) from the string buffer encoded with the type type.
Load a certificate request (X509Req) from the string buffer encoded with the type type.
Load a private key (PKey) from the string buffer encoded with the type type (must be one of FILETYPE_PEM and FILETYPE_ASN1).
passphrase must be either a string or a callback for providing the pass phrase.
Load Certificate Revocation List (CRL) data from a string buffer. buffer encoded with the type type. The type type must either FILETYPE_PEM or FILETYPE_ASN1).
Load pkcs7 data from the string buffer encoded with the type type.
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().
Sign a data string using the given key and message digest.
key is a PKey instance. data is a str instance. digest is a str naming a supported message digest type, for example sha1.
New in version 0.11.
Verify the signature for a data string.
certificate is a X509 instance 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 example sha1.
New in version 0.11.
X509 objects have the following methods:
Return an X509Name object representing the issuer of the certificate.
Return the certificate serial number.
Return the signature algorithm used in the certificate. If the algorithm is undefined, raise ValueError.
Return the certificate version.
Return a string giving the time before which the certificate is not valid. The string is formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ
YYYYMMDDhhmmss+hhmm
YYYYMMDDhhmmss-hhmm
If no value exists for this field, None is returned.
Return a string giving the time after which the certificate is not valid. The string is formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ
YYYYMMDDhhmmss+hhmm
YYYYMMDDhhmmss-hhmm
If no value exists for this field, None is returned.
Change the time before which the certificate is not valid. when is a string formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ
YYYYMMDDhhmmss+hhmm
YYYYMMDDhhmmss-hhmm
Change the time after which the certificate is not valid. when is a string formatted as an ASN1 GENERALIZEDTIME:
YYYYMMDDhhmmssZ
YYYYMMDDhhmmss+hhmm
YYYYMMDDhhmmss-hhmm
Adjust the timestamp (in GMT) when the certificate starts being valid.
Adjust the timestamp (in GMT) when the certificate stops being valid.
Checks the certificate’s time stamp against current time. Returns true if the certificate has expired and false otherwise.
Set the issuer of the certificate to issuer.
Set the public key of the certificate to pkey.
Set the serial number of the certificate to serialno.
Set the subject of the certificate to subject.
Set the certificate version to version.
Sign the certificate, using the key pkey and the message digest algorithm identified by the string digest.
Return the hash of the certificate subject.
Return a digest of the certificate, using the digest_name method. digest_name must be a string describing a digest algorithm supported by OpenSSL (by EVP_get_digestbyname, specifically). For example, "md5" or "sha1".
Add the extensions in the sequence extensions to the certificate.
Return the number of extensions on this certificate.
New in version 0.12.
Retrieve the extension on this certificate at the given index.
Extensions on a certificate are kept in order. The index parameter selects which extension will be returned. The returned object will be an X509Extension instance.
New in version 0.12.
X509Name objects have the following methods:
Return an integer giving the first four bytes of the MD5 digest of the DER representation of the name.
Return a string giving the DER representation of the name.
Return a list of two-tuples of strings giving the components of the name.
X509Name objects have the following members:
The country of the entity. C may be used as an alias for countryName.
The state or province of the entity. ST may be used as an alias for stateOrProvinceName ·
The locality of the entity. L may be used as an alias for localityName.
The organization name of the entity. O may be used as an alias for organizationName.
The organizational unit of the entity. OU may be used as an alias for organizationalUnitName.
The common name of the entity. CN may be used as an alias for commonName.
The e-mail address of the entity.
X509Req objects have the following methods:
Set the public key of the certificate request to pkey.
Sign the certificate request, using the key pkey and the message digest algorithm identified by the string digest.
Verify a certificate request using the public key pkey.
Set the version (RFC 2459, 4.1.2.1) of the certificate request to version.
Get the version (RFC 2459, 4.1.2.1) of the certificate request.
The X509Store object has currently just one method:
Add the certificate cert to the certificate store.
The PKey object has the following methods:
Return the number of bits of the key.
Generate a public/private key pair of the type type (one of TYPE_RSA and TYPE_DSA) with the size bits.
Return the type of the key.
Check the consistency of this key, returning True if it is consistent and raising an exception otherwise. This is only valid for RSA keys. See the OpenSSL RSA_check_key man page for further limitations.
PKCS7 objects have the following methods:
FIXME
FIXME
FIXME
FIXME
Get the type name of the PKCS7.
PKCS12 objects have the following methods:
Returns a PKCS12 object as a string.
The optional passphrase must be a string not a callback.
See also the man page for the C function PKCS12_create().
Return CA certificates within the PKCS12 object as a tuple. Returns None if no CA certificates are present.
Return certificate portion of the PKCS12 structure.
Return friendlyName portion of the PKCS12 structure.
Return private key portion of the PKCS12 structure
Replace or set the CA certificates within the PKCS12 object with the sequence cacerts.
Set cacerts to None to remove all CA certificates.
Replace or set the certificate portion of the PKCS12 structure.
Replace or set the friendlyName portion of the PKCS12 structure.
Replace or set private key portion of the PKCS12 structure
X509Extension objects have several methods:
Return the critical field of the extension object.
Retrieve the short descriptive name for this extension.
The result is a byte string like basicConstraints.
New in version 0.12.
Retrieve the data for this extension.
The result is the ASN.1 encoded form of the extension data as a byte string.
New in version 0.12.
NetscapeSPKI objects have the following methods:
Return a base64-encoded string representation of the object.
Return the public key of object.
Set the public key of the object to key.
Sign the NetscapeSPKI object using the given key and digest_name. digest_name must be a string describing a digest algorithm supported by OpenSSL (by EVP_get_digestbyname, specifically). For example, "md5" or "sha1".
Verify the NetscapeSPKI object using the given key.
CRL objects have the following methods:
Add a Revoked object to the CRL, by value not reference.
Use cert and key to sign the CRL and return the CRL as a string. days is the number of days before the next CRL is due.
Return a tuple of Revoked objects, by value not reference.
Revoked objects have the following methods:
Return a list of all supported reasons.
Return the revocation reason as a str. Can be None, which differs from “Unspecified”.
Return the revocation date as a str. The string is formatted as an ASN1 GENERALIZEDTIME.
Return a str containing a hex number of the serial of the revoked certificate.
Set the revocation reason. reason must be None or a string, but the values are limited. Spaces and case are ignored. See all_reasons().
Set the revocation date. The string is formatted as an ASN1 GENERALIZEDTIME.
serial is a string containing a hex number of the serial of the revoked certificate.