summaryrefslogtreecommitdiff
path: root/doc/html/openssl-x509.html
blob: ab814a3f66e64facbbc3e993a7aec4e951474197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.1.2 X509 objects </title>
<META NAME="description" CONTENT="3.1.2 X509 objects ">
<META NAME="keywords" CONTENT="pyOpenSSL">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<link rel="STYLESHEET" href="pyOpenSSL.css">
<LINK REL="next" href="openssl-x509name.html">
<LINK REL="previous" href="openssl-x509ext.html">
<LINK REL="up" href="openssl-crypto.html">
<LINK REL="next" href="openssl-x509name.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="openssl-x509ext.html"><img src="previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="openssl-crypto.html"><img src="up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="openssl-x509name.html"><img src="next.gif"
  border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python OpenSSL Manual</td>
<td><A href="contents.html"><img src="contents.gif"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><img src="blank.gif"
  border="0" height="32"
  alt="" width="32"></td>
<td><img src="blank.gif"
  border="0" height="32"
  alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-x509ext.html">3.1.1 X509Extension objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto  </A>
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509name.html">3.1.3 X509Name objects</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->

<H3><A NAME="SECTION000412000000000000000">&nbsp;</A>
<BR>
3.1.2 X509 objects 
</H3>

<P>
X509 objects have the following methods:

<P>
<dl><dt><b><a name='l2h-41'><tt class='method'>get_issuer</tt></a></b>()
<dd>
Return an X509Name object representing the issuer of the certificate.
</dl>

<P>
<dl><dt><b><a name='l2h-42'><tt class='method'>get_pubkey</tt></a></b>()
<dd>
Return a PKey object representing the public key of the certificate.
</dl>

<P>
<dl><dt><b><a name='l2h-43'><tt class='method'>get_serial_number</tt></a></b>()
<dd>
Return the certificate serial number.
</dl>

<P>
<dl><dt><b><a name='l2h-44'><tt class='method'>get_subject</tt></a></b>()
<dd>
Return an X509Name object representing the subject of the certificate.
</dl>

<P>
<dl><dt><b><a name='l2h-45'><tt class='method'>get_version</tt></a></b>()
<dd>
Return the certificate version.
</dl>

<P>
<dl><dt><b><a name='l2h-46'><tt class='method'>get_notBefore</tt></a></b>()
<dd>
Return a string giving the time before which the certificate is not valid.  The
string is formatted as an ASN1 GENERALIZEDTIME:
<dl><dd><pre class="verbatim">
                 YYYYMMDDhhmmssZ
                 YYYYMMDDhhmmss+hhmm
                 YYYYMMDDhhmmss-hhmm
</pre></dl>
If no value exists for this field, <code>None</code> is returned.
</dl>

<P>
<dl><dt><b><a name='l2h-47'><tt class='method'>get_notAfter</tt></a></b>()
<dd>
Return a string giving the time after which the certificate is not valid.  The
string is formatted as an ASN1 GENERALIZEDTIME:
<dl><dd><pre class="verbatim">
                 YYYYMMDDhhmmssZ
                 YYYYMMDDhhmmss+hhmm
                 YYYYMMDDhhmmss-hhmm
</pre></dl>
If no value exists for this field, <code>None</code> is returned.
</dl>

<P>
<dl><dt><b><a name='l2h-48'><tt class='method'>set_notBefore</tt></a></b>(<var>when</var>)
<dd>
Change the time before which the certificate is not valid.  <var>when</var> is a
string formatted as an ASN1 GENERALIZEDTIME:
<dl><dd><pre class="verbatim">
                 YYYYMMDDhhmmssZ
                 YYYYMMDDhhmmss+hhmm
                 YYYYMMDDhhmmss-hhmm
</pre></dl>
</dl>

<P>
<dl><dt><b><a name='l2h-49'><tt class='method'>set_notAfter</tt></a></b>(<var>when</var>)
<dd>
Change the time after which the certificate is not valid.  <var>when</var> is a
string formatted as an ASN1 GENERALIZEDTIME:
<dl><dd><pre class="verbatim">
                 YYYYMMDDhhmmssZ
                 YYYYMMDDhhmmss+hhmm
                 YYYYMMDDhhmmss-hhmm
</pre></dl>
</dl>

<P>
<dl><dt><b><a name='l2h-50'><tt class='method'>gmtime_adj_notBefore</tt></a></b>(<var>time</var>)
<dd>
Adjust the timestamp (in GMT) when the certificate starts being valid.
</dl>

<P>
<dl><dt><b><a name='l2h-51'><tt class='method'>gmtime_adj_notAfter</tt></a></b>(<var>time</var>)
<dd>
Adjust the timestamp (in GMT) when the certificate stops being valid.
</dl>

<P>
<dl><dt><b><a name='l2h-52'><tt class='method'>has_expired</tt></a></b>()
<dd>
Checks the certificate's time stamp against current time. Returns true if the
certificate has expired and false otherwise.
</dl>

<P>
<dl><dt><b><a name='l2h-53'><tt class='method'>set_issuer</tt></a></b>(<var>issuer</var>)
<dd>
Set the issuer of the certificate to <var>issuer</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-54'><tt class='method'>set_pubkey</tt></a></b>(<var>pkey</var>)
<dd>
Set the public key of the certificate to <var>pkey</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-55'><tt class='method'>set_serial_number</tt></a></b>(<var>serialno</var>)
<dd>
Set the serial number of the certificate to <var>serialno</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-56'><tt class='method'>set_subject</tt></a></b>(<var>subject</var>)
<dd>
Set the subject of the certificate to <var>subject</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-57'><tt class='method'>set_version</tt></a></b>(<var>version</var>)
<dd>
Set the certificate version to <var>version</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-58'><tt class='method'>sign</tt></a></b>(<var>pkey, digest</var>)
<dd>
Sign the certificate, using the key <var>pkey</var> and the message digest algorithm
identified by the string <var>digest</var>.
</dl>

<P>
<dl><dt><b><a name='l2h-59'><tt class='method'>subject_name_hash</tt></a></b>()
<dd>
Return the hash of the certificate subject.
</dl>

<P>
<dl><dt><b><a name='l2h-60'><tt class='method'>digest</tt></a></b>(<var>digest_name</var>)
<dd>
Return a digest of the certificate, using the <var>digest_name</var> method.
<var>digest_name</var> must be a string describing a digest algorithm supported
by OpenSSL (by EVP_get_digestbyname, specifically).  For example,
<tt class="constant">"md5"</tt> or <tt class="constant">"sha1"</tt>.
</dl>

<P>
<dl><dt><b><a name='l2h-61'><tt class='method'>add_extensions</tt></a></b>(<var>extensions</var>)
<dd>
Add the extensions in the sequence <var>extensions</var> to the certificate.
</dl>

<P>
<dl><dt><b><a name='l2h-62'><tt class='method'>get_extension_count</tt></a></b>()
<dd>
Return the number of extensions on this certificate.

<span class='versionnote'>New in version 0.12.</span>

</dl>

<P>
<dl><dt><b><a name='l2h-63'><tt class='method'>get_extension</tt></a></b>(<var>index</var>)
<dd>
Retrieve the extension on this certificate at the given index.

<P>
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.

<span class='versionnote'>New in version 0.12.</span>

</dl>

<P>

<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="openssl-x509ext.html"><img src="previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="openssl-crypto.html"><img src="up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="openssl-x509name.html"><img src="next.gif"
  border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python OpenSSL Manual</td>
<td><A href="contents.html"><img src="contents.gif"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><img src="blank.gif"
  border="0" height="32"
  alt="" width="32"></td>
<td><img src="blank.gif"
  border="0" height="32"
  alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-x509ext.html">3.1.1 X509Extension objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="openssl-crypto.html">3.1 crypto  </A>
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-x509name.html">3.1.3 X509Name objects</A>
<hr>
<span class="release-info">Release 0.12.</span>
</DIV>
<!--End of Navigation Panel-->

</BODY>
</HTML>