blob: 8787e04752b9f57fdad21c6e53cd4e63ab6d213d [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>
94</dl>
95
96<P>
97<dl><dt><b><a name='l2h-40'><tt class='method'>get_notAfter</tt></a></b>()
98<dd>
99Return a string giving the time after which the certificate is not valid. The
100string is formatted as an ASN1 GENERALIZEDTIME:
101<dl><dd><pre class="verbatim">
102 YYYYMMDDhhmmssZ
103 YYYYMMDDhhmmss+hhmm
104 YYYYMMDDhhmmss-hhmm
105</pre></dl>
106</dl>
107
108<P>
109<dl><dt><b><a name='l2h-41'><tt class='method'>set_notBefore</tt></a></b>(<var>when</var>)
110<dd>
111Change the time before which the certificate is not valid. <var>when</var> is a
112string formatted as an ASN1 GENERALIZEDTIME:
113<dl><dd><pre class="verbatim">
114 YYYYMMDDhhmmssZ
115 YYYYMMDDhhmmss+hhmm
116 YYYYMMDDhhmmss-hhmm
117</pre></dl>
118</dl>
119
120<P>
121<dl><dt><b><a name='l2h-42'><tt class='method'>set_notAfter</tt></a></b>(<var>when</var>)
122<dd>
123Change the time after which the certificate is not valid. <var>when</var> is a
124string formatted as an ASN1 GENERALIZEDTIME:
125<dl><dd><pre class="verbatim">
126 YYYYMMDDhhmmssZ
127 YYYYMMDDhhmmss+hhmm
128 YYYYMMDDhhmmss-hhmm
129</pre></dl>
130</dl>
131
132<P>
133<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 -0500134<dd>
135Adjust the timestamp (in GMT) when the certificate starts being valid.
136</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500137
138<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400139<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 -0500140<dd>
141Adjust the timestamp (in GMT) when the certificate stops being valid.
142</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500143
144<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400145<dl><dt><b><a name='l2h-45'><tt class='method'>has_expired</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500146<dd>
147Checks the certificate's time stamp against current time. Returns true if the
148certificate has expired and false otherwise.
149</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500150
151<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400152<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 -0500153<dd>
154Set the issuer of the certificate to <var>issuer</var>.
155</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500156
157<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400158<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 -0500159<dd>
160Set the public key of the certificate to <var>pkey</var>.
161</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500162
163<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400164<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 -0500165<dd>
166Set the serial number of the certificate to <var>serialno</var>.
167</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500168
169<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400170<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 -0500171<dd>
172Set the subject of the certificate to <var>subject</var>.
173</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500174
175<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400176<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 -0500177<dd>
178Set the certificate version to <var>version</var>.
179</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500180
181<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400182<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 -0500183<dd>
184Sign the certificate, using the key <var>pkey</var> and the message digest algorithm
185identified by the string <var>digest</var>.
186</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500187
188<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400189<dl><dt><b><a name='l2h-52'><tt class='method'>subject_name_hash</tt></a></b>()
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500190<dd>
191Return the hash of the certificate subject.
192</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500193
194<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400195<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 -0500196<dd>
197Return a digest of the certificate, using the <var>digest_name</var> method.
198</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500199
200<P>
Jean-Paul Calderone525ef802008-03-09 20:39:42 -0400201<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 -0500202<dd>
203Add the extensions in the sequence <var>extensions</var> to the certificate.
204</dl>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500205
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500206<P>
Jean-Paul Calderone2aa2b332008-03-06 21:43:14 -0500207
Jean-Paul Calderone897bc252008-02-18 20:50:23 -0500208<DIV CLASS="navigation">
209<p><hr>
210<table align="center" width="100%" cellpadding="0" cellspacing="2">
211<tr>
212<td><A href="openssl-crypto.html"><img src="previous.gif"
213border="0" height="32"
214 alt="Previous Page" width="32"></A></td>
215<td><A href="openssl-crypto.html"><img src="up.gif"
216border="0" height="32"
217 alt="Up One Level" width="32"></A></td>
218<td><A href="openssl-x509name.html"><img src="next.gif"
219border="0" height="32"
220 alt="Next Page" width="32"></A></td>
221<td align="center" width="100%">Python OpenSSL Manual</td>
222<td><A href="contents.html"><img src="contents.gif"
223border="0" height="32"
224 alt="Contents" width="32"></A></td>
225<td><img src="blank.gif"
226 border="0" height="32"
227 alt="" width="32"></td>
228<td><img src="blank.gif"
229 border="0" height="32"
230 alt="" width="32"></td>
231</tr></table>
232<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
233<b class="navlabel">Up:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto </A>
234<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509name.html">3.1.2 X509Name objects</A>
235<hr>
236<span class="release-info">Release 0.6.</span>
237</DIV>
238<!--End of Navigation Panel-->
239
240</BODY>
241</HTML>