17
17
<table align="center" width="100%" cellpadding="0" cellspacing="2">
19
19
<td><A href="openssl-ssl.html"><img src="previous.gif"
20
border="0" height="32"
20
border="0" height="32"
21
21
alt="Previous Page" width="32"></A></td>
22
22
<td><A href="openssl-ssl.html"><img src="up.gif"
23
border="0" height="32"
23
border="0" height="32"
24
24
alt="Up One Level" width="32"></A></td>
25
25
<td><A href="openssl-connection.html"><img src="next.gif"
26
border="0" height="32"
26
border="0" height="32"
27
27
alt="Next Page" width="32"></A></td>
28
28
<td align="center" width="100%">Python OpenSSL Manual</td>
29
29
<td><A href="contents.html"><img src="contents.gif"
30
border="0" height="32"
30
border="0" height="32"
31
31
alt="Contents" width="32"></A></td>
32
32
<td><img src="blank.gif"
33
33
border="0" height="32"
52
52
Context objects have the following methods:
55
<dl><dt><b><a name='l2h-124'><tt class='method'>check_privatekey</tt></a></b>()
55
<dl><dt><b><a name='l2h-133'><tt class='method'>check_privatekey</tt></a></b>()
57
57
Check if the private key (loaded with <tt class="method">use_privatekey<big>[</big>_file<big>]</big></tt>)
58
58
matches the certificate (loaded with <tt class="method">use_certificate<big>[</big>_file<big>]</big></tt>).
63
<dl><dt><b><a name='l2h-125'><tt class='method'>get_app_data</tt></a></b>()
63
<dl><dt><b><a name='l2h-134'><tt class='method'>get_app_data</tt></a></b>()
65
65
Retrieve application data as set by <tt class="method">set_app_data</tt>.
69
<dl><dt><b><a name='l2h-126'><tt class='method'>get_cert_store</tt></a></b>()
69
<dl><dt><b><a name='l2h-135'><tt class='method'>get_cert_store</tt></a></b>()
71
71
Retrieve the certificate store (a X509Store object) that the context uses.
72
72
This can be used to add "trusted" certificates without using the.
77
<dl><dt><b><a name='l2h-127'><tt class='method'>get_timeout</tt></a></b>()
77
<dl><dt><b><a name='l2h-136'><tt class='method'>get_timeout</tt></a></b>()
79
79
Retrieve session timeout, as set by <tt class="method">set_timeout</tt>. The default is 300
84
<dl><dt><b><a name='l2h-128'><tt class='method'>get_verify_depth</tt></a></b>()
84
<dl><dt><b><a name='l2h-137'><tt class='method'>get_verify_depth</tt></a></b>()
86
86
Retrieve the Context object's verify depth, as set by
87
87
<tt class="method">set_verify_depth</tt>.
91
<dl><dt><b><a name='l2h-129'><tt class='method'>get_verify_mode</tt></a></b>()
91
<dl><dt><b><a name='l2h-138'><tt class='method'>get_verify_mode</tt></a></b>()
93
93
Retrieve the Context object's verify mode, as set by <tt class="method">set_verify</tt>.
97
<dl><dt><b><a name='l2h-130'><tt class='method'>load_client_ca</tt></a></b>(<var>pemfile</var>)
97
<dl><dt><b><a name='l2h-139'><tt class='method'>load_client_ca</tt></a></b>(<var>pemfile</var>)
99
99
Read a file with PEM-formatted certificates that will be sent to the client
100
100
when requesting a client certificate.
104
<dl><dt><b><a name='l2h-131'><tt class='method'>load_verify_locations</tt></a></b>(<var>pemfile, capath</var>)
104
<dl><dt><b><a name='l2h-140'><tt class='method'>set_client_ca_list</tt></a></b>(<var>certificate_authorities</var>)
106
Replace the current list of preferred certificate signers that would be
107
sent to the client when requesting a client certificate with the
108
<var>certificate_authorities</var> sequence of <tt class="class">OpenSSL.crypto.X509Name</tt>s.
112
<span class='versionnote'>New in version 0.10.</span>
117
<dl><dt><b><a name='l2h-141'><tt class='method'>add_client_ca</tt></a></b>(<var>certificate_authority</var>)
119
Extract a <tt class="class">OpenSSL.crypto.X509Name</tt> from the <var>certificate_authority</var>
120
<tt class="class">OpenSSL.crypto.X509</tt> certificate and add it to the list of preferred
121
certificate signers sent to the client when requesting a client certificate.
125
<span class='versionnote'>New in version 0.10.</span>
130
<dl><dt><b><a name='l2h-142'><tt class='method'>load_verify_locations</tt></a></b>(<var>pemfile, capath</var>)
106
132
Specify where CA certificates for verification purposes are located. These
107
133
are trusted certificates. Note that the certificates have to be in PEM
114
<dl><dt><b><a name='l2h-132'><tt class='method'>set_default_verify_paths</tt></a></b>()
140
<dl><dt><b><a name='l2h-143'><tt class='method'>set_default_verify_paths</tt></a></b>()
116
142
Specify that the platform provided CA certificates are to be used for
117
143
verification purposes. This method may not work properly on OS X.
121
<dl><dt><b><a name='l2h-133'><tt class='method'>load_tmp_dh</tt></a></b>(<var>dhfile</var>)
147
<dl><dt><b><a name='l2h-144'><tt class='method'>load_tmp_dh</tt></a></b>(<var>dhfile</var>)
123
149
Load parameters for Ephemeral Diffie-Hellman from <var>dhfile</var>.
127
<dl><dt><b><a name='l2h-134'><tt class='method'>set_app_data</tt></a></b>(<var>data</var>)
153
<dl><dt><b><a name='l2h-145'><tt class='method'>set_app_data</tt></a></b>(<var>data</var>)
129
155
Associate <var>data</var> with this Context object. <var>data</var> can be retrieved
130
156
later using the <tt class="method">get_app_data</tt> method.
134
<dl><dt><b><a name='l2h-135'><tt class='method'>set_cipher_list</tt></a></b>(<var>ciphers</var>)
160
<dl><dt><b><a name='l2h-146'><tt class='method'>set_cipher_list</tt></a></b>(<var>ciphers</var>)
136
162
Set the list of ciphers to be used in this context. See the OpenSSL manual for
137
163
more information (e.g. ciphers(1))
141
<dl><dt><b><a name='l2h-136'><tt class='method'>set_info_callback</tt></a></b>(<var>callback</var>)
167
<dl><dt><b><a name='l2h-147'><tt class='method'>set_info_callback</tt></a></b>(<var>callback</var>)
143
169
Set the information callback to <var>callback</var>. This function will be called
144
170
from time to time during SSL handshakes.
152
<dl><dt><b><a name='l2h-137'><tt class='method'>set_options</tt></a></b>(<var>options</var>)
178
<dl><dt><b><a name='l2h-148'><tt class='method'>set_options</tt></a></b>(<var>options</var>)
154
180
Add SSL options. Options you have set before are not cleared!
155
181
This method should be used with the <tt class="constant">OP_*</tt> constants.
159
<dl><dt><b><a name='l2h-138'><tt class='method'>set_passwd_cb</tt></a></b>(<var>callback</var><big>[</big><var>, userdata</var><big>]</big>)
185
<dl><dt><b><a name='l2h-149'><tt class='method'>set_passwd_cb</tt></a></b>(<var>callback</var><big>[</big><var>, userdata</var><big>]</big>)
161
187
Set the passphrase callback to <var>callback</var>. This function will be called
162
188
when a private key with a passphrase is loaded. <var>callback</var> must accept
173
<dl><dt><b><a name='l2h-139'><tt class='method'>set_session_id</tt></a></b>(<var>name</var>)
199
<dl><dt><b><a name='l2h-150'><tt class='method'>set_session_id</tt></a></b>(<var>name</var>)
175
201
Set the context <var>name</var> within which a session can be reused for this
176
202
Context object. This is needed when doing session resumption, because there is
182
<dl><dt><b><a name='l2h-140'><tt class='method'>set_timeout</tt></a></b>(<var>timeout</var>)
208
<dl><dt><b><a name='l2h-151'><tt class='method'>set_timeout</tt></a></b>(<var>timeout</var>)
184
210
Set the timeout for newly created sessions for this Context object to
185
211
<var>timeout</var>. <var>timeout</var> must be given in (whole) seconds. The default
191
<dl><dt><b><a name='l2h-141'><tt class='method'>set_verify</tt></a></b>(<var>mode, callback</var>)
217
<dl><dt><b><a name='l2h-152'><tt class='method'>set_verify</tt></a></b>(<var>mode, callback</var>)
193
219
Set the verification flags for this Context object to <var>mode</var> and specify
194
220
that <var>callback</var> should be used for verification callbacks. <var>mode</var>
206
<dl><dt><b><a name='l2h-142'><tt class='method'>set_verify_depth</tt></a></b>(<var>depth</var>)
232
<dl><dt><b><a name='l2h-153'><tt class='method'>set_verify_depth</tt></a></b>(<var>depth</var>)
208
234
Set the maximum depth for the certificate chain verification that shall be
209
235
allowed for this Context object.
213
<dl><dt><b><a name='l2h-143'><tt class='method'>use_certificate</tt></a></b>(<var>cert</var>)
239
<dl><dt><b><a name='l2h-154'><tt class='method'>use_certificate</tt></a></b>(<var>cert</var>)
215
241
Use the certificate <var>cert</var> which has to be a X509 object.
219
<dl><dt><b><a name='l2h-144'><tt class='method'>add_extra_chain_cert</tt></a></b>(<var>cert</var>)
245
<dl><dt><b><a name='l2h-155'><tt class='method'>add_extra_chain_cert</tt></a></b>(<var>cert</var>)
221
247
Adds the certificate <var>cert</var>, which has to be a X509 object, to the
222
248
certificate chain presented together with the certificate.
226
<dl><dt><b><a name='l2h-145'><tt class='method'>use_certificate_chain_file</tt></a></b>(<var>file</var>)
252
<dl><dt><b><a name='l2h-156'><tt class='method'>use_certificate_chain_file</tt></a></b>(<var>file</var>)
228
254
Load a certificate chain from <var>file</var> which must be PEM encoded.
232
<dl><dt><b><a name='l2h-146'><tt class='method'>use_privatekey</tt></a></b>(<var>pkey</var>)
258
<dl><dt><b><a name='l2h-157'><tt class='method'>use_privatekey</tt></a></b>(<var>pkey</var>)
234
260
Use the private key <var>pkey</var> which has to be a PKey object.
238
<dl><dt><b><a name='l2h-147'><tt class='method'>use_certificate_file</tt></a></b>(<var>file</var><big>[</big><var>, format</var><big>]</big>)
264
<dl><dt><b><a name='l2h-158'><tt class='method'>use_certificate_file</tt></a></b>(<var>file</var><big>[</big><var>, format</var><big>]</big>)
240
266
Load the first certificate found in <var>file</var>. The certificate must be in the
241
267
format specified by <var>format</var>, which is either <tt class="constant">FILETYPE_PEM</tt> or
246
<dl><dt><b><a name='l2h-148'><tt class='method'>use_privatekey_file</tt></a></b>(<var>file</var><big>[</big><var>, format</var><big>]</big>)
272
<dl><dt><b><a name='l2h-159'><tt class='method'>use_privatekey_file</tt></a></b>(<var>file</var><big>[</big><var>, format</var><big>]</big>)
248
274
Load the first private key found in <var>file</var>. The private key must be in the
249
275
format specified by <var>format</var>, which is either <tt class="constant">FILETYPE_PEM</tt> or
257
283
<table align="center" width="100%" cellpadding="0" cellspacing="2">
259
285
<td><A href="openssl-ssl.html"><img src="previous.gif"
260
border="0" height="32"
286
border="0" height="32"
261
287
alt="Previous Page" width="32"></A></td>
262
288
<td><A href="openssl-ssl.html"><img src="up.gif"
263
border="0" height="32"
289
border="0" height="32"
264
290
alt="Up One Level" width="32"></A></td>
265
291
<td><A href="openssl-connection.html"><img src="next.gif"
266
border="0" height="32"
292
border="0" height="32"
267
293
alt="Next Page" width="32"></A></td>
268
294
<td align="center" width="100%">Python OpenSSL Manual</td>
269
295
<td><A href="contents.html"><img src="contents.gif"
270
border="0" height="32"
296
border="0" height="32"
271
297
alt="Contents" width="32"></A></td>
272
298
<td><img src="blank.gif"
273
299
border="0" height="32"
280
306
<b class="navlabel">Up:</b> <a class="sectref" href="openssl-ssl.html">3.3 SSL </A>
281
307
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-connection.html">3.3.2 Connection objects</A>
283
<span class="release-info">Release 0.9.</span>
309
<span class="release-info">Release 0.10.</span>
285
311
<!--End of Navigation Panel-->