blob: 6110745c3e463dfc309b493ca75f29fae346c08a [file] [log] [blame]
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
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">
14</head>
15<body>
16<DIV CLASS="navigation">
17<table align="center" width="100%" cellpadding="0" cellspacing="2">
18<tr>
19<td><A href="openssl-crypto.html"><img src="previous.gif"
20border="0" height="32"
21 alt="Previous Page" width="32"></A></td>
22<td><A href="openssl-crypto.html"><img src="up.gif"
23border="0" height="32"
24 alt="Up One Level" width="32"></A></td>
25<td><A href="openssl-x509name.html"><img src="next.gif"
26border="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"
30border="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>
38</tr></table>
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>
42<br><hr>
43</DIV>
44<!--End of Navigation Panel-->
45
46<H3><A NAME="SECTION000411000000000000000">&nbsp;</A>
47<BR>
483.1.1 X509 objects
49</H3>
50
51<P>
52X509 objects have the following methods:
53
54<P>
55<dl><dt><b><a name='l2h-34'><tt class='method'>get_issuer</tt></a></b>()
56<dd>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -050057Return an X509Name object representing the issuer of the certificate.
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050058</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -050059
60<P>
61<dl><dt><b><a name='l2h-35'><tt class='method'>get_pubkey</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050062<dd>
63Return a PKey object representing the public key of the certificate.
64</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -050065
66<P>
67<dl><dt><b><a name='l2h-36'><tt class='method'>get_serial_number</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050068<dd>
69Return the certificate serial number.
70</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -050071
72<P>
73<dl><dt><b><a name='l2h-37'><tt class='method'>get_subject</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050074<dd>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -050075Return an X509Name object representing the subject of the certificate.
76</dl>
77
78<P>
79<dl><dt><b><a name='l2h-38'><tt class='method'>get_version</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -050080<dd>
81Return the certificate version.
82</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -050083
84<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -040085<dl><dt><b><a name='l2h-39'><tt class='method'>get_notBefore</tt></a></b>()
86<dd>
87Return a string giving the time before which the certificate is not valid. The
88string is formatted as an ASN1 GENERALIZEDTIME:
89<dl><dd><pre class="verbatim">
90 YYYYMMDDhhmmssZ
91 YYYYMMDDhhmmss+hhmm
92 YYYYMMDDhhmmss-hhmm
93</pre></dl>
Jean-Paul Calderone24c99262008-03-09 21:48:06 -040094If no value exists for this field, <code>None</code> is returned.
Jean-Paul Calderone525ef802008-03-09 20:39:42 -040095</dl>
96
97<P>
98<dl><dt><b><a name='l2h-40'><tt class='method'>get_notAfter</tt></a></b>()
99<dd>
100Return a string giving the time after which the certificate is not valid. The
101string is formatted as an ASN1 GENERALIZEDTIME:
102<dl><dd><pre class="verbatim">
103 YYYYMMDDhhmmssZ
104 YYYYMMDDhhmmss+hhmm
105 YYYYMMDDhhmmss-hhmm
106</pre></dl>
Jean-Paul Calderone24c99262008-03-09 21:48:06 -0400107If no value exists for this field, <code>None</code> is returned.
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400108</dl>
109
110<P>
111<dl><dt><b><a name='l2h-41'><tt class='method'>set_notBefore</tt></a></b>(<var>when</var>)
112<dd>
113Change the time before which the certificate is not valid. <var>when</var> is a
114string formatted as an ASN1 GENERALIZEDTIME:
115<dl><dd><pre class="verbatim">
116 YYYYMMDDhhmmssZ
117 YYYYMMDDhhmmss+hhmm
118 YYYYMMDDhhmmss-hhmm
119</pre></dl>
120</dl>
121
122<P>
123<dl><dt><b><a name='l2h-42'><tt class='method'>set_notAfter</tt></a></b>(<var>when</var>)
124<dd>
125Change the time after which the certificate is not valid. <var>when</var> is a
126string formatted as an ASN1 GENERALIZEDTIME:
127<dl><dd><pre class="verbatim">
128 YYYYMMDDhhmmssZ
129 YYYYMMDDhhmmss+hhmm
130 YYYYMMDDhhmmss-hhmm
131</pre></dl>
132</dl>
133
134<P>
135<dl><dt><b><a name='l2h-43'><tt class='method'>gmtime_adj_notBefore</tt></a></b>(<var>time</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500136<dd>
137Adjust the timestamp (in GMT) when the certificate starts being valid.
138</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500139
140<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400141<dl><dt><b><a name='l2h-44'><tt class='method'>gmtime_adj_notAfter</tt></a></b>(<var>time</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500142<dd>
143Adjust the timestamp (in GMT) when the certificate stops being valid.
144</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500145
146<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400147<dl><dt><b><a name='l2h-45'><tt class='method'>has_expired</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500148<dd>
149Checks the certificate's time stamp against current time. Returns true if the
150certificate has expired and false otherwise.
151</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500152
153<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400154<dl><dt><b><a name='l2h-46'><tt class='method'>set_issuer</tt></a></b>(<var>issuer</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500155<dd>
156Set the issuer of the certificate to <var>issuer</var>.
157</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500158
159<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400160<dl><dt><b><a name='l2h-47'><tt class='method'>set_pubkey</tt></a></b>(<var>pkey</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500161<dd>
162Set the public key of the certificate to <var>pkey</var>.
163</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500164
165<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400166<dl><dt><b><a name='l2h-48'><tt class='method'>set_serial_number</tt></a></b>(<var>serialno</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500167<dd>
168Set the serial number of the certificate to <var>serialno</var>.
169</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500170
171<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400172<dl><dt><b><a name='l2h-49'><tt class='method'>set_subject</tt></a></b>(<var>subject</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500173<dd>
174Set the subject of the certificate to <var>subject</var>.
175</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500176
177<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400178<dl><dt><b><a name='l2h-50'><tt class='method'>set_version</tt></a></b>(<var>version</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500179<dd>
180Set the certificate version to <var>version</var>.
181</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500182
183<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400184<dl><dt><b><a name='l2h-51'><tt class='method'>sign</tt></a></b>(<var>pkey, digest</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500185<dd>
186Sign the certificate, using the key <var>pkey</var> and the message digest algorithm
187identified by the string <var>digest</var>.
188</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500189
190<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400191<dl><dt><b><a name='l2h-52'><tt class='method'>subject_name_hash</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500192<dd>
193Return the hash of the certificate subject.
194</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500195
196<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400197<dl><dt><b><a name='l2h-53'><tt class='method'>digest</tt></a></b>(<var>digest_name</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500198<dd>
199Return a digest of the certificate, using the <var>digest_name</var> method.
200</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500201
202<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400203<dl><dt><b><a name='l2h-54'><tt class='method'>add_extensions</tt></a></b>(<var>extensions</var>)
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500204<dd>
205Add the extensions in the sequence <var>extensions</var> to the certificate.
206</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500207
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500208<P>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500209
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500210<DIV CLASS="navigation">
211<p><hr>
212<table align="center" width="100%" cellpadding="0" cellspacing="2">
213<tr>
214<td><A href="openssl-crypto.html"><img src="previous.gif"
215border="0" height="32"
216 alt="Previous Page" width="32"></A></td>
217<td><A href="openssl-crypto.html"><img src="up.gif"
218border="0" height="32"
219 alt="Up One Level" width="32"></A></td>
220<td><A href="openssl-x509name.html"><img src="next.gif"
221border="0" height="32"
222 alt="Next Page" width="32"></A></td>
223<td align="center" width="100%">Python OpenSSL Manual</td>
224<td><A href="contents.html"><img src="contents.gif"
225border="0" height="32"
226 alt="Contents" width="32"></A></td>
227<td><img src="blank.gif"
228 border="0" height="32"
229 alt="" width="32"></td>
230<td><img src="blank.gif"
231 border="0" height="32"
232 alt="" width="32"></td>
233</tr></table>
234<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
235<b class="navlabel">Up:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
236<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509name.html">3.1.2 X509Name objects</A>
237<hr>
Jean-Paul Calderonef1b839d2008-09-01 12:06:06 -0400238<span class="release-info">Release 0.7.</span>
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500239</DIV>
240<!--End of Navigation Panel-->
241
242</BODY>
243</HTML>