52
52
Context objects have the following methods:
55
<dl><dt><b><a name='l2h-148'><tt class='method'>check_privatekey</tt></a></b>()
55
<dl><dt><b><a name='l2h-152'><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-149'><tt class='method'>get_app_data</tt></a></b>()
63
<dl><dt><b><a name='l2h-153'><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-150'><tt class='method'>get_cert_store</tt></a></b>()
69
<dl><dt><b><a name='l2h-154'><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-151'><tt class='method'>get_timeout</tt></a></b>()
77
<dl><dt><b><a name='l2h-155'><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-152'><tt class='method'>get_verify_depth</tt></a></b>()
84
<dl><dt><b><a name='l2h-156'><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-153'><tt class='method'>get_verify_mode</tt></a></b>()
91
<dl><dt><b><a name='l2h-157'><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-154'><tt class='method'>load_client_ca</tt></a></b>(<var>pemfile</var>)
97
<dl><dt><b><a name='l2h-158'><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-155'><tt class='method'>set_client_ca_list</tt></a></b>(<var>certificate_authorities</var>)
104
<dl><dt><b><a name='l2h-159'><tt class='method'>set_client_ca_list</tt></a></b>(<var>certificate_authorities</var>)
106
106
Replace the current list of preferred certificate signers that would be
107
107
sent to the client when requesting a client certificate with the
117
<dl><dt><b><a name='l2h-156'><tt class='method'>add_client_ca</tt></a></b>(<var>certificate_authority</var>)
117
<dl><dt><b><a name='l2h-160'><tt class='method'>add_client_ca</tt></a></b>(<var>certificate_authority</var>)
119
119
Extract a <tt class="class">OpenSSL.crypto.X509Name</tt> from the <var>certificate_authority</var>
120
120
<tt class="class">OpenSSL.crypto.X509</tt> certificate and add it to the list of preferred
130
<dl><dt><b><a name='l2h-157'><tt class='method'>load_verify_locations</tt></a></b>(<var>pemfile, capath</var>)
130
<dl><dt><b><a name='l2h-161'><tt class='method'>load_verify_locations</tt></a></b>(<var>pemfile, capath</var>)
132
132
Specify where CA certificates for verification purposes are located. These
133
133
are trusted certificates. Note that the certificates have to be in PEM
140
<dl><dt><b><a name='l2h-158'><tt class='method'>set_default_verify_paths</tt></a></b>()
140
<dl><dt><b><a name='l2h-162'><tt class='method'>set_default_verify_paths</tt></a></b>()
142
142
Specify that the platform provided CA certificates are to be used for
143
143
verification purposes. This method may not work properly on OS X.
147
<dl><dt><b><a name='l2h-159'><tt class='method'>load_tmp_dh</tt></a></b>(<var>dhfile</var>)
147
<dl><dt><b><a name='l2h-163'><tt class='method'>load_tmp_dh</tt></a></b>(<var>dhfile</var>)
149
149
Load parameters for Ephemeral Diffie-Hellman from <var>dhfile</var>.
153
<dl><dt><b><a name='l2h-160'><tt class='method'>set_app_data</tt></a></b>(<var>data</var>)
153
<dl><dt><b><a name='l2h-164'><tt class='method'>set_app_data</tt></a></b>(<var>data</var>)
155
155
Associate <var>data</var> with this Context object. <var>data</var> can be retrieved
156
156
later using the <tt class="method">get_app_data</tt> method.
160
<dl><dt><b><a name='l2h-161'><tt class='method'>set_cipher_list</tt></a></b>(<var>ciphers</var>)
160
<dl><dt><b><a name='l2h-165'><tt class='method'>set_cipher_list</tt></a></b>(<var>ciphers</var>)
162
162
Set the list of ciphers to be used in this context. See the OpenSSL manual for
163
163
more information (e.g. ciphers(1))
167
<dl><dt><b><a name='l2h-162'><tt class='method'>set_info_callback</tt></a></b>(<var>callback</var>)
167
<dl><dt><b><a name='l2h-166'><tt class='method'>set_info_callback</tt></a></b>(<var>callback</var>)
169
169
Set the information callback to <var>callback</var>. This function will be called
170
170
from time to time during SSL handshakes.
178
<dl><dt><b><a name='l2h-163'><tt class='method'>set_options</tt></a></b>(<var>options</var>)
178
<dl><dt><b><a name='l2h-167'><tt class='method'>set_options</tt></a></b>(<var>options</var>)
180
180
Add SSL options. Options you have set before are not cleared!
181
181
This method should be used with the <tt class="constant">OP_*</tt> constants.
185
<dl><dt><b><a name='l2h-164'><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-168'><tt class='method'>set_passwd_cb</tt></a></b>(<var>callback</var><big>[</big><var>, userdata</var><big>]</big>)
187
187
Set the passphrase callback to <var>callback</var>. This function will be called
188
188
when a private key with a passphrase is loaded. <var>callback</var> must accept
199
<dl><dt><b><a name='l2h-165'><tt class='method'>set_session_id</tt></a></b>(<var>name</var>)
199
<dl><dt><b><a name='l2h-169'><tt class='method'>set_session_id</tt></a></b>(<var>name</var>)
201
201
Set the context <var>name</var> within which a session can be reused for this
202
202
Context object. This is needed when doing session resumption, because there is
208
<dl><dt><b><a name='l2h-166'><tt class='method'>set_timeout</tt></a></b>(<var>timeout</var>)
208
<dl><dt><b><a name='l2h-170'><tt class='method'>set_timeout</tt></a></b>(<var>timeout</var>)
210
210
Set the timeout for newly created sessions for this Context object to
211
211
<var>timeout</var>. <var>timeout</var> must be given in (whole) seconds. The default
217
<dl><dt><b><a name='l2h-167'><tt class='method'>set_verify</tt></a></b>(<var>mode, callback</var>)
217
<dl><dt><b><a name='l2h-171'><tt class='method'>set_verify</tt></a></b>(<var>mode, callback</var>)
219
219
Set the verification flags for this Context object to <var>mode</var> and specify
220
220
that <var>callback</var> should be used for verification callbacks. <var>mode</var>
232
<dl><dt><b><a name='l2h-168'><tt class='method'>set_verify_depth</tt></a></b>(<var>depth</var>)
232
<dl><dt><b><a name='l2h-172'><tt class='method'>set_verify_depth</tt></a></b>(<var>depth</var>)
234
234
Set the maximum depth for the certificate chain verification that shall be
235
235
allowed for this Context object.
239
<dl><dt><b><a name='l2h-169'><tt class='method'>use_certificate</tt></a></b>(<var>cert</var>)
239
<dl><dt><b><a name='l2h-173'><tt class='method'>use_certificate</tt></a></b>(<var>cert</var>)
241
241
Use the certificate <var>cert</var> which has to be a X509 object.
245
<dl><dt><b><a name='l2h-170'><tt class='method'>add_extra_chain_cert</tt></a></b>(<var>cert</var>)
245
<dl><dt><b><a name='l2h-174'><tt class='method'>add_extra_chain_cert</tt></a></b>(<var>cert</var>)
247
247
Adds the certificate <var>cert</var>, which has to be a X509 object, to the
248
248
certificate chain presented together with the certificate.
252
<dl><dt><b><a name='l2h-171'><tt class='method'>use_certificate_chain_file</tt></a></b>(<var>file</var>)
252
<dl><dt><b><a name='l2h-175'><tt class='method'>use_certificate_chain_file</tt></a></b>(<var>file</var>)
254
254
Load a certificate chain from <var>file</var> which must be PEM encoded.
258
<dl><dt><b><a name='l2h-172'><tt class='method'>use_privatekey</tt></a></b>(<var>pkey</var>)
258
<dl><dt><b><a name='l2h-176'><tt class='method'>use_privatekey</tt></a></b>(<var>pkey</var>)
260
260
Use the private key <var>pkey</var> which has to be a PKey object.
264
<dl><dt><b><a name='l2h-173'><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-177'><tt class='method'>use_certificate_file</tt></a></b>(<var>file</var><big>[</big><var>, format</var><big>]</big>)
266
266
Load the first certificate found in <var>file</var>. The certificate must be in the
267
267
format specified by <var>format</var>, which is either <tt class="constant">FILETYPE_PEM</tt> or
272
<dl><dt><b><a name='l2h-174'><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-178'><tt class='method'>use_privatekey_file</tt></a></b>(<var>file</var><big>[</big><var>, format</var><big>]</big>)
274
274
Load the first private key found in <var>file</var>. The private key must be in the
275
275
format specified by <var>format</var>, which is either <tt class="constant">FILETYPE_PEM</tt> or