3.1.1 X509 objects

X509 objects have the following methods:

get_issuer()
Return an X509Name object representing the issuer of the certificate.

get_pubkey()
Return a PKey object representing the public key of the certificate.

get_serial_number()
Return the certificate serial number.

get_subject()
Return an X509Name object representing the subject of the certificate.

get_version()
Return the certificate version.

get_notBefore()
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.

get_notAfter()
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.

set_notBefore(when)
Change the time before which the certificate is not valid. when is a string formatted as an ASN1 GENERALIZEDTIME:
                 YYYYMMDDhhmmssZ
                 YYYYMMDDhhmmss+hhmm
                 YYYYMMDDhhmmss-hhmm

set_notAfter(when)
Change the time after which the certificate is not valid. when is a string formatted as an ASN1 GENERALIZEDTIME:
                 YYYYMMDDhhmmssZ
                 YYYYMMDDhhmmss+hhmm
                 YYYYMMDDhhmmss-hhmm

gmtime_adj_notBefore(time)
Adjust the timestamp (in GMT) when the certificate starts being valid.

gmtime_adj_notAfter(time)
Adjust the timestamp (in GMT) when the certificate stops being valid.

has_expired()
Checks the certificate's time stamp against current time. Returns true if the certificate has expired and false otherwise.

set_issuer(issuer)
Set the issuer of the certificate to issuer.

set_pubkey(pkey)
Set the public key of the certificate to pkey.

set_serial_number(serialno)
Set the serial number of the certificate to serialno.

set_subject(subject)
Set the subject of the certificate to subject.

set_version(version)
Set the certificate version to version.

sign(pkey, digest)
Sign the certificate, using the key pkey and the message digest algorithm identified by the string digest.

subject_name_hash()
Return the hash of the certificate subject.

digest(digest_name)
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_extensions(extensions)
Add the extensions in the sequence extensions to the certificate.