Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 1 | <!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" |
| 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> |
| 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"> </A> |
| 47 | <BR> |
| 48 | 3.1.1 X509 objects |
| 49 | </H3> |
| 50 | |
| 51 | <P> |
| 52 | X509 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 Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 57 | Return an X509Name object representing the issuer of the certificate. |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 58 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 59 | |
| 60 | <P> |
| 61 | <dl><dt><b><a name='l2h-35'><tt class='method'>get_pubkey</tt></a></b>() |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 62 | <dd> |
| 63 | Return a PKey object representing the public key of the certificate. |
| 64 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 65 | |
| 66 | <P> |
| 67 | <dl><dt><b><a name='l2h-36'><tt class='method'>get_serial_number</tt></a></b>() |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 68 | <dd> |
| 69 | Return the certificate serial number. |
| 70 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 71 | |
| 72 | <P> |
| 73 | <dl><dt><b><a name='l2h-37'><tt class='method'>get_subject</tt></a></b>() |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 74 | <dd> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 75 | Return 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 Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 80 | <dd> |
| 81 | Return the certificate version. |
| 82 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 83 | |
| 84 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 85 | <dl><dt><b><a name='l2h-39'><tt class='method'>get_notBefore</tt></a></b>() |
| 86 | <dd> |
| 87 | Return a string giving the time before which the certificate is not valid. The |
| 88 | string 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 Calderone | 24c9926 | 2008-03-09 21:48:06 -0400 | [diff] [blame] | 94 | If no value exists for this field, <code>None</code> is returned. |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 95 | </dl> |
| 96 | |
| 97 | <P> |
| 98 | <dl><dt><b><a name='l2h-40'><tt class='method'>get_notAfter</tt></a></b>() |
| 99 | <dd> |
| 100 | Return a string giving the time after which the certificate is not valid. The |
| 101 | string 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 Calderone | 24c9926 | 2008-03-09 21:48:06 -0400 | [diff] [blame] | 107 | If no value exists for this field, <code>None</code> is returned. |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 108 | </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> |
| 113 | Change the time before which the certificate is not valid. <var>when</var> is a |
| 114 | string 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> |
| 125 | Change the time after which the certificate is not valid. <var>when</var> is a |
| 126 | string 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 Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 136 | <dd> |
| 137 | Adjust the timestamp (in GMT) when the certificate starts being valid. |
| 138 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 139 | |
| 140 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 141 | <dl><dt><b><a name='l2h-44'><tt class='method'>gmtime_adj_notAfter</tt></a></b>(<var>time</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 142 | <dd> |
| 143 | Adjust the timestamp (in GMT) when the certificate stops being valid. |
| 144 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 145 | |
| 146 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 147 | <dl><dt><b><a name='l2h-45'><tt class='method'>has_expired</tt></a></b>() |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 148 | <dd> |
| 149 | Checks the certificate's time stamp against current time. Returns true if the |
| 150 | certificate has expired and false otherwise. |
| 151 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 152 | |
| 153 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 154 | <dl><dt><b><a name='l2h-46'><tt class='method'>set_issuer</tt></a></b>(<var>issuer</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 155 | <dd> |
| 156 | Set the issuer of the certificate to <var>issuer</var>. |
| 157 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 158 | |
| 159 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 160 | <dl><dt><b><a name='l2h-47'><tt class='method'>set_pubkey</tt></a></b>(<var>pkey</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 161 | <dd> |
| 162 | Set the public key of the certificate to <var>pkey</var>. |
| 163 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 164 | |
| 165 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 166 | <dl><dt><b><a name='l2h-48'><tt class='method'>set_serial_number</tt></a></b>(<var>serialno</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 167 | <dd> |
| 168 | Set the serial number of the certificate to <var>serialno</var>. |
| 169 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 170 | |
| 171 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 172 | <dl><dt><b><a name='l2h-49'><tt class='method'>set_subject</tt></a></b>(<var>subject</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 173 | <dd> |
| 174 | Set the subject of the certificate to <var>subject</var>. |
| 175 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 176 | |
| 177 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 178 | <dl><dt><b><a name='l2h-50'><tt class='method'>set_version</tt></a></b>(<var>version</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 179 | <dd> |
| 180 | Set the certificate version to <var>version</var>. |
| 181 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 182 | |
| 183 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 184 | <dl><dt><b><a name='l2h-51'><tt class='method'>sign</tt></a></b>(<var>pkey, digest</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 185 | <dd> |
| 186 | Sign the certificate, using the key <var>pkey</var> and the message digest algorithm |
| 187 | identified by the string <var>digest</var>. |
| 188 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 189 | |
| 190 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 191 | <dl><dt><b><a name='l2h-52'><tt class='method'>subject_name_hash</tt></a></b>() |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 192 | <dd> |
| 193 | Return the hash of the certificate subject. |
| 194 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 195 | |
| 196 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 197 | <dl><dt><b><a name='l2h-53'><tt class='method'>digest</tt></a></b>(<var>digest_name</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 198 | <dd> |
| 199 | Return a digest of the certificate, using the <var>digest_name</var> method. |
| 200 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 201 | |
| 202 | <P> |
Jean-Paul Calderone | 525ef80 | 2008-03-09 20:39:42 -0400 | [diff] [blame] | 203 | <dl><dt><b><a name='l2h-54'><tt class='method'>add_extensions</tt></a></b>(<var>extensions</var>) |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 204 | <dd> |
| 205 | Add the extensions in the sequence <var>extensions</var> to the certificate. |
| 206 | </dl> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 207 | |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 208 | <P> |
Jean-Paul Calderone | 2aa2b33 | 2008-03-06 21:43:14 -0500 | [diff] [blame] | 209 | |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 210 | <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" |
| 215 | border="0" height="32" |
| 216 | alt="Previous Page" width="32"></A></td> |
| 217 | <td><A href="openssl-crypto.html"><img src="up.gif" |
| 218 | border="0" height="32" |
| 219 | alt="Up One Level" width="32"></A></td> |
| 220 | <td><A href="openssl-x509name.html"><img src="next.gif" |
| 221 | border="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" |
| 225 | border="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 Calderone | f1b839d | 2008-09-01 12:06:06 -0400 | [diff] [blame] | 238 | <span class="release-info">Release 0.7.</span> |
Jean-Paul Calderone | 897bc25 | 2008-02-18 20:50:23 -0500 | [diff] [blame] | 239 | </DIV> |
| 240 | <!--End of Navigation Panel--> |
| 241 | |
| 242 | </BODY> |
| 243 | </HTML> |