1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
4
<title>3.1.1 X509 objects </title>
5
<META NAME="description" CONTENT="3.1.1 X509 objects ">
6
<META NAME="keywords" CONTENT="pyOpenSSL">
7
<META NAME="resource-type" CONTENT="document">
8
<META NAME="distribution" CONTENT="global">
9
<link rel="STYLESHEET" href="pyOpenSSL.css">
10
<LINK REL="next" href="openssl-x509name.html">
11
<LINK REL="previous" href="openssl-crypto.html">
12
<LINK REL="up" href="openssl-crypto.html">
13
<LINK REL="next" href="openssl-x509name.html">
16
<DIV CLASS="navigation">
17
<table align="center" width="100%" cellpadding="0" cellspacing="2">
19
<td><A href="openssl-crypto.html"><img src="previous.gif"
20
border="0" height="32"
21
alt="Previous Page" width="32"></A></td>
22
<td><A href="openssl-crypto.html"><img src="up.gif"
23
border="0" height="32"
24
alt="Up One Level" width="32"></A></td>
25
<td><A href="openssl-x509name.html"><img src="next.gif"
26
border="0" height="32"
27
alt="Next Page" width="32"></A></td>
28
<td align="center" width="100%">Python OpenSSL Manual</td>
29
<td><A href="contents.html"><img src="contents.gif"
30
border="0" height="32"
31
alt="Contents" width="32"></A></td>
32
<td><img src="blank.gif"
33
border="0" height="32"
34
alt="" width="32"></td>
35
<td><img src="blank.gif"
36
border="0" height="32"
37
alt="" width="32"></td>
39
<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
40
<b class="navlabel">Up:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
41
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509name.html">3.1.2 X509Name objects</A>
44
<!--End of Navigation Panel-->
46
<H3><A NAME="SECTION000411000000000000000"> </A>
52
X509 objects have the following methods:
55
<dl><dt><b><a name='l2h-39'><tt class='method'>get_issuer</tt></a></b>()
57
Return an X509Name object representing the issuer of the certificate.
61
<dl><dt><b><a name='l2h-40'><tt class='method'>get_pubkey</tt></a></b>()
63
Return a PKey object representing the public key of the certificate.
67
<dl><dt><b><a name='l2h-41'><tt class='method'>get_serial_number</tt></a></b>()
69
Return the certificate serial number.
73
<dl><dt><b><a name='l2h-42'><tt class='method'>get_signature_algorithm</tt></a></b>()
75
Return the signature algorithm used in the certificate. If the algorithm is
76
undefined, raise <code>ValueError</code>.
80
<dl><dt><b><a name='l2h-43'><tt class='method'>get_subject</tt></a></b>()
82
Return an X509Name object representing the subject of the certificate.
86
<dl><dt><b><a name='l2h-44'><tt class='method'>get_version</tt></a></b>()
88
Return the certificate version.
92
<dl><dt><b><a name='l2h-45'><tt class='method'>get_notBefore</tt></a></b>()
94
Return a string giving the time before which the certificate is not valid. The
95
string is formatted as an ASN1 GENERALIZEDTIME:
96
<dl><dd><pre class="verbatim">
101
If no value exists for this field, <code>None</code> is returned.
105
<dl><dt><b><a name='l2h-46'><tt class='method'>get_notAfter</tt></a></b>()
107
Return a string giving the time after which the certificate is not valid. The
108
string is formatted as an ASN1 GENERALIZEDTIME:
109
<dl><dd><pre class="verbatim">
114
If no value exists for this field, <code>None</code> is returned.
118
<dl><dt><b><a name='l2h-47'><tt class='method'>set_notBefore</tt></a></b>(<var>when</var>)
120
Change the time before which the certificate is not valid. <var>when</var> is a
121
string formatted as an ASN1 GENERALIZEDTIME:
122
<dl><dd><pre class="verbatim">
130
<dl><dt><b><a name='l2h-48'><tt class='method'>set_notAfter</tt></a></b>(<var>when</var>)
132
Change the time after which the certificate is not valid. <var>when</var> is a
133
string formatted as an ASN1 GENERALIZEDTIME:
134
<dl><dd><pre class="verbatim">
142
<dl><dt><b><a name='l2h-49'><tt class='method'>gmtime_adj_notBefore</tt></a></b>(<var>time</var>)
144
Adjust the timestamp (in GMT) when the certificate starts being valid.
148
<dl><dt><b><a name='l2h-50'><tt class='method'>gmtime_adj_notAfter</tt></a></b>(<var>time</var>)
150
Adjust the timestamp (in GMT) when the certificate stops being valid.
154
<dl><dt><b><a name='l2h-51'><tt class='method'>has_expired</tt></a></b>()
156
Checks the certificate's time stamp against current time. Returns true if the
157
certificate has expired and false otherwise.
161
<dl><dt><b><a name='l2h-52'><tt class='method'>set_issuer</tt></a></b>(<var>issuer</var>)
163
Set the issuer of the certificate to <var>issuer</var>.
167
<dl><dt><b><a name='l2h-53'><tt class='method'>set_pubkey</tt></a></b>(<var>pkey</var>)
169
Set the public key of the certificate to <var>pkey</var>.
173
<dl><dt><b><a name='l2h-54'><tt class='method'>set_serial_number</tt></a></b>(<var>serialno</var>)
175
Set the serial number of the certificate to <var>serialno</var>.
179
<dl><dt><b><a name='l2h-55'><tt class='method'>set_subject</tt></a></b>(<var>subject</var>)
181
Set the subject of the certificate to <var>subject</var>.
185
<dl><dt><b><a name='l2h-56'><tt class='method'>set_version</tt></a></b>(<var>version</var>)
187
Set the certificate version to <var>version</var>.
191
<dl><dt><b><a name='l2h-57'><tt class='method'>sign</tt></a></b>(<var>pkey, digest</var>)
193
Sign the certificate, using the key <var>pkey</var> and the message digest algorithm
194
identified by the string <var>digest</var>.
198
<dl><dt><b><a name='l2h-58'><tt class='method'>subject_name_hash</tt></a></b>()
200
Return the hash of the certificate subject.
204
<dl><dt><b><a name='l2h-59'><tt class='method'>digest</tt></a></b>(<var>digest_name</var>)
206
Return a digest of the certificate, using the <var>digest_name</var> method.
207
<var>digest_name</var> must be a string describing a digest algorithm supported
208
by OpenSSL (by EVP_get_digestbyname, specifically). For example,
209
<tt class="constant">"md5"</tt> or <tt class="constant">"sha1"</tt>.
213
<dl><dt><b><a name='l2h-60'><tt class='method'>add_extensions</tt></a></b>(<var>extensions</var>)
215
Add the extensions in the sequence <var>extensions</var> to the certificate.
219
<dl><dt><b><a name='l2h-61'><tt class='method'>get_extension_count</tt></a></b>()
221
Return the number of extensions on this certificate.
223
<span class='versionnote'>New in version 0.12.</span>
228
<dl><dt><b><a name='l2h-62'><tt class='method'>get_extension</tt></a></b>(<var>index</var>)
230
Retrieve the extension on this certificate at the given index.
233
Extensions on a certificate are kept in order. The index parameter selects
234
which extension will be returned. The returned object will be an X509Extension
237
<span class='versionnote'>New in version 0.12.</span>
243
<DIV CLASS="navigation">
245
<table align="center" width="100%" cellpadding="0" cellspacing="2">
247
<td><A href="openssl-crypto.html"><img src="previous.gif"
248
border="0" height="32"
249
alt="Previous Page" width="32"></A></td>
250
<td><A href="openssl-crypto.html"><img src="up.gif"
251
border="0" height="32"
252
alt="Up One Level" width="32"></A></td>
253
<td><A href="openssl-x509name.html"><img src="next.gif"
254
border="0" height="32"
255
alt="Next Page" width="32"></A></td>
256
<td align="center" width="100%">Python OpenSSL Manual</td>
257
<td><A href="contents.html"><img src="contents.gif"
258
border="0" height="32"
259
alt="Contents" width="32"></A></td>
260
<td><img src="blank.gif"
261
border="0" height="32"
262
alt="" width="32"></td>
263
<td><img src="blank.gif"
264
border="0" height="32"
265
alt="" width="32"></td>
267
<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
268
<b class="navlabel">Up:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
269
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509name.html">3.1.2 X509Name objects</A>
271
<span class="release-info">Release 0.13.</span>
273
<!--End of Navigation Panel-->