~exarkun/pyopenssl/trunk

« back to all changes in this revision

Viewing changes to doc/html/openssl-ssl.html

  • Committer: Jean-Paul Calderone
  • Date: 2011-09-11 19:49:43 UTC
  • mfrom: (156.3.22 sphinx-doc)
  • Revision ID: exarkun@divmod.com-20110911194943-ucaan2tzidk7ek5l
Convert the documentation from LaTeX/epytext to Sphinx/ReST

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
 
<html>
3
 
<head>
4
 
<title>3.3 SSL -- An interface to the SSL-specific parts of OpenSSL </title>
5
 
<META NAME="description" CONTENT="3.3 SSL -- An interface to the SSL-specific parts of OpenSSL ">
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="previous" href="openssl-rand.html">
11
 
<LINK REL="up" href="openssl.html">
12
 
<LINK REL="next" href="openssl-context.html">
13
 
</head>
14
 
<body>
15
 
<DIV CLASS="navigation">
16
 
<table align="center" width="100%" cellpadding="0" cellspacing="2">
17
 
<tr>
18
 
<td><A href="openssl-rand.html"><img src="previous.gif"
19
 
  border="0" height="32"
20
 
  alt="Previous Page" width="32"></A></td>
21
 
<td><A href="openssl.html"><img src="up.gif"
22
 
  border="0" height="32"
23
 
  alt="Up One Level" width="32"></A></td>
24
 
<td><A href="openssl-context.html"><img src="next.gif"
25
 
  border="0" height="32"
26
 
  alt="Next Page" width="32"></A></td>
27
 
<td align="center" width="100%">Python OpenSSL Manual</td>
28
 
<td><A href="contents.html"><img src="contents.gif"
29
 
  border="0" height="32"
30
 
  alt="Contents" width="32"></A></td>
31
 
<td><img src="blank.gif"
32
 
  border="0" height="32"
33
 
  alt="" width="32"></td>
34
 
<td><img src="blank.gif"
35
 
  border="0" height="32"
36
 
  alt="" width="32"></td>
37
 
</tr></table>
38
 
<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-rand.html">3.2 rand  </A>
39
 
<b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL  </A>
40
 
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-context.html">3.3.1 Context objects</A>
41
 
<br><hr>
42
 
</DIV>
43
 
<!--End of Navigation Panel-->
44
 
 
45
 
<H2><A NAME="SECTION000430000000000000000">&nbsp;</A>
46
 
<BR>
47
 
3.3 <tt class="module">SSL</tt> -- An interface to the SSL-specific parts of OpenSSL 
48
 
</H2>
49
 
 
50
 
<P>
51
 
 
52
 
 
53
 
<P>
54
 
This module handles things specific to SSL. There are two objects defined:
55
 
Context, Connection.
56
 
 
57
 
<P>
58
 
<dl><dt><b><a name='l2h-129'><tt>SSLv2_METHOD</tt></a></b>
59
 
<dd>
60
 
<dt><b><a name='l2h-146'><tt>SSLv3_METHOD</tt></a></b><dd>
61
 
<dt><b><a name='l2h-147'><tt>SSLv23_METHOD</tt></a></b><dd>
62
 
<dt><b><a name='l2h-148'><tt>TLSv1_METHOD</tt></a></b><dd>
63
 
These constants represent the different SSL methods to use when creating a
64
 
context object.
65
 
</dl>
66
 
 
67
 
<P>
68
 
<dl><dt><b><a name='l2h-130'><tt>VERIFY_NONE</tt></a></b>
69
 
<dd>
70
 
<dt><b><a name='l2h-149'><tt>VERIFY_PEER</tt></a></b><dd>
71
 
<dt><b><a name='l2h-150'><tt>VERIFY_FAIL_IF_NO_PEER_CERT</tt></a></b><dd>
72
 
These constants represent the verification mode used by the Context
73
 
object's <tt class="method">set_verify</tt> method.
74
 
</dl>
75
 
 
76
 
<P>
77
 
<dl><dt><b><a name='l2h-131'><tt>FILETYPE_PEM</tt></a></b>
78
 
<dd>
79
 
<dt><b><a name='l2h-151'><tt>FILETYPE_ASN1</tt></a></b><dd>
80
 
File type constants used with the <tt class="method">use_certificate_file</tt> and
81
 
<tt class="method">use_privatekey_file</tt> methods of Context objects.
82
 
</dl>
83
 
 
84
 
<P>
85
 
<dl><dt><b><a name='l2h-132'><tt>OP_SINGLE_DH_USE</tt></a></b>
86
 
<dd>
87
 
<dt><b><a name='l2h-152'><tt>OP_EPHEMERAL_RSA</tt></a></b><dd>
88
 
<dt><b><a name='l2h-153'><tt>OP_NO_SSLv2</tt></a></b><dd>
89
 
<dt><b><a name='l2h-154'><tt>OP_NO_SSLv3</tt></a></b><dd>
90
 
<dt><b><a name='l2h-155'><tt>OP_NO_TLSv1</tt></a></b><dd>
91
 
Constants used with <tt class="method">set_options</tt> of Context objects.
92
 
<tt class="constant">OP_SINGLE_DH_USE</tt> means to always create a new key when using ephemeral
93
 
Diffie-Hellman. <tt class="constant">OP_EPHEMERAL_RSA</tt> means to always use ephemeral RSA keys
94
 
when doing RSA operations. <tt class="constant">OP_NO_SSLv2</tt>, <tt class="constant">OP_NO_SSLv3</tt> and
95
 
<tt class="constant">OP_NO_TLSv1</tt> means to disable those specific protocols. This is
96
 
interesting if you're using e.g. <tt class="constant">SSLv23_METHOD</tt> to get an SSLv2-compatible
97
 
handshake, but don't want to use SSLv2.
98
 
</dl>
99
 
 
100
 
<P>
101
 
<dl><dt><b><a name='l2h-133'><tt>SSLEAY_VERSION</tt></a></b>
102
 
<dd>
103
 
<dt><b><a name='l2h-156'><tt>SSLEAY_CFLAGS</tt></a></b><dd>
104
 
<dt><b><a name='l2h-157'><tt>SSLEAY_BUILT_ON</tt></a></b><dd>
105
 
<dt><b><a name='l2h-158'><tt>SSLEAY_PLATFORM</tt></a></b><dd>
106
 
<dt><b><a name='l2h-159'><tt>SSLEAY_DIR</tt></a></b><dd>
107
 
Constants used with <tt class="method">SSLeay_version</tt> to specify what OpenSSL version
108
 
information to retrieve.  See the man page for the <tt class="function">SSLeay_version</tt> C
109
 
API for details.
110
 
</dl>
111
 
 
112
 
<P>
113
 
<dl><dt><b><a name='l2h-134'><tt>OPENSSL_VERSION_NUMBER</tt></a></b>
114
 
<dd>
115
 
An integer giving the version number of the OpenSSL library used to build this
116
 
version of pyOpenSSL.  See the man page for the <tt class="function">SSLeay_version</tt> C API
117
 
for details.
118
 
</dl>
119
 
 
120
 
<P>
121
 
<dl><dt><b><a name='l2h-135'><tt class='function'>SSLeay_version</tt></a></b>(<var>type</var>)
122
 
<dd>
123
 
Retrieve a string describing some aspect of the underlying OpenSSL version.  The
124
 
type passed in should be one of the <tt class="constant">SSLEAY_*</tt> constants defined in
125
 
this module.
126
 
</dl>
127
 
 
128
 
<P>
129
 
<dl><dt><b><a name='l2h-136'><tt>ContextType</tt></a></b>
130
 
<dd>
131
 
See <tt class="class">Context</tt>.
132
 
</dl>
133
 
 
134
 
<P>
135
 
<dl><dt><b>class <a name='l2h-137'><tt class='class'>Context</tt></a></b>(<var>method</var>)
136
 
<dd>
137
 
A class representing SSL contexts.  Contexts define the parameters of one or
138
 
more SSL connections.
139
 
 
140
 
<P>
141
 
<var>method</var> should be <tt class="constant">SSLv2_METHOD</tt>, <tt class="constant">SSLv3_METHOD</tt>,
142
 
<tt class="constant">SSLv23_METHOD</tt> or <tt class="constant">TLSv1_METHOD</tt>.
143
 
</dl>
144
 
 
145
 
<P>
146
 
<dl><dt><b><a name='l2h-138'><tt>ConnectionType</tt></a></b>
147
 
<dd>
148
 
See <tt class="class">Connection</tt>.
149
 
</dl>
150
 
 
151
 
<P>
152
 
<dl><dt><b>class <a name='l2h-139'><tt class='class'>Connection</tt></a></b>(<var>context, socket</var>)
153
 
<dd>
154
 
A class representing SSL connections.
155
 
 
156
 
<P>
157
 
<var>context</var> should be an instance of <tt class="class">Context</tt> and <var>socket</var>
158
 
should be a socket <A NAME="tex2html4"
159
 
  HREF="#foot1276"><SUP>3</SUP></A> object.  <var>socket</var> may be
160
 
<var>None</var>; in this case, the Connection is created with a memory BIO: see
161
 
the <tt class="method">bio_read</tt>, <tt class="method">bio_write</tt>, and <tt class="method">bio_shutdown</tt>
162
 
methods.
163
 
</dl>
164
 
 
165
 
<P>
166
 
<dl><dt><b>exception <a name='l2h-140'><tt class='exception'>Error</tt></a></b>
167
 
<dd>
168
 
This exception is used as a base class for the other SSL-related
169
 
exceptions, but may also be raised directly.
170
 
 
171
 
<P>
172
 
Whenever this exception is raised directly, it has a list of error messages
173
 
from the OpenSSL error queue, where each item is a tuple <code>(<var>lib</var>,
174
 
<var>function</var>, <var>reason</var>)</code>. Here <var>lib</var>, <var>function</var> and <var>reason</var>
175
 
are all strings, describing where and what the problem is. See <span class='manpage'><i>err</i>(3)</span>
176
 
for more information.
177
 
</dl>
178
 
 
179
 
<P>
180
 
<dl><dt><b>exception <a name='l2h-141'><tt class='exception'>ZeroReturnError</tt></a></b>
181
 
<dd>
182
 
This exception matches the error return code <code>SSL_ERROR_ZERO_RETURN</code>, and
183
 
is raised when the SSL Connection has been closed. In SSL 3.0 and TLS 1.0, this
184
 
only occurs if a closure alert has occurred in the protocol, i.e. the
185
 
connection has been closed cleanly. Note that this does not necessarily
186
 
mean that the transport layer (e.g. a socket) has been closed.
187
 
 
188
 
<P>
189
 
It may seem a little strange that this is an exception, but it does match an
190
 
<code>SSL_ERROR</code> code, and is very convenient.
191
 
</dl>
192
 
 
193
 
<P>
194
 
<dl><dt><b>exception <a name='l2h-142'><tt class='exception'>WantReadError</tt></a></b>
195
 
<dd>
196
 
The operation did not complete; the same I/O method should be called again
197
 
later, with the same arguments. Any I/O method can lead to this since new
198
 
handshakes can occur at any time.
199
 
 
200
 
<P>
201
 
The wanted read is for <i>dirty</i> data sent over the network, not the
202
 
<i>clean</i> data inside the tunnel.  For a socket based SSL connection,
203
 
<i>read</i> means data coming at us over the network.  Until that read
204
 
succeeds, the attempted <tt class="method">OpenSSL.SSL.Connection.recv</tt>,
205
 
<tt class="method">OpenSSL.SSL.Connection.send</tt>, or
206
 
<tt class="method">OpenSSL.SSL.Connection.do_handshake</tt> is prevented or incomplete. You
207
 
probably want to <tt class="method">select()</tt> on the socket before trying again.
208
 
</dl>
209
 
 
210
 
<P>
211
 
<dl><dt><b>exception <a name='l2h-143'><tt class='exception'>WantWriteError</tt></a></b>
212
 
<dd>
213
 
See <tt class="exception">WantReadError</tt>.  The socket send buffer may be too full to
214
 
write more data.
215
 
</dl>
216
 
 
217
 
<P>
218
 
<dl><dt><b>exception <a name='l2h-144'><tt class='exception'>WantX509LookupError</tt></a></b>
219
 
<dd>
220
 
The operation did not complete because an application callback has asked to be
221
 
called again. The I/O method should be called again later, with the same
222
 
arguments. Note: This won't occur in this version, as there are no such
223
 
callbacks in this version.
224
 
</dl>
225
 
 
226
 
<P>
227
 
<dl><dt><b>exception <a name='l2h-145'><tt class='exception'>SysCallError</tt></a></b>
228
 
<dd>
229
 
The <tt class="exception">SysCallError</tt> occurs when there's an I/O error and OpenSSL's
230
 
error queue does not contain any information. This can mean two things: An
231
 
error in the transport protocol, or an end of file that violates the protocol.
232
 
The parameter to the exception is always a pair <code>(<var>errnum</var>,
233
 
<var>errstr</var>)</code>.
234
 
</dl>
235
 
 
236
 
<P>
237
 
<BR><HR><H4>Footnotes</H4>
238
 
<DL>
239
 
<DT><A NAME="foot1276">... socket</A><A
240
 
 href="openssl-ssl.html#tex2html4"><SUP>3</SUP></A></DT>
241
 
<DD>Actually, all that is required is an object
242
 
that <i>behaves</i> like a socket, you could even use files, even though
243
 
it'd be tricky to get the handshakes right!
244
 
 
245
 
</DD>
246
 
</DL>
247
 
<p><hr>
248
 
<!--Table of Child-Links-->
249
 
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
250
 
 
251
 
<UL CLASS="ChildLinks">
252
 
<LI><A NAME="tex2html289"
253
 
  href="openssl-context.html">3.3.1 Context objects </A>
254
 
<LI><A NAME="tex2html290"
255
 
  href="openssl-connection.html">3.3.2 Connection objects </A>
256
 
</UL>
257
 
<!--End of Table of Child-Links-->
258
 
 
259
 
<DIV CLASS="navigation">
260
 
<p><hr>
261
 
<table align="center" width="100%" cellpadding="0" cellspacing="2">
262
 
<tr>
263
 
<td><A href="openssl-rand.html"><img src="previous.gif"
264
 
  border="0" height="32"
265
 
  alt="Previous Page" width="32"></A></td>
266
 
<td><A href="openssl.html"><img src="up.gif"
267
 
  border="0" height="32"
268
 
  alt="Up One Level" width="32"></A></td>
269
 
<td><A href="openssl-context.html"><img src="next.gif"
270
 
  border="0" height="32"
271
 
  alt="Next Page" width="32"></A></td>
272
 
<td align="center" width="100%">Python OpenSSL Manual</td>
273
 
<td><A href="contents.html"><img src="contents.gif"
274
 
  border="0" height="32"
275
 
  alt="Contents" width="32"></A></td>
276
 
<td><img src="blank.gif"
277
 
  border="0" height="32"
278
 
  alt="" width="32"></td>
279
 
<td><img src="blank.gif"
280
 
  border="0" height="32"
281
 
  alt="" width="32"></td>
282
 
</tr></table>
283
 
<b class="navlabel">Previous:</b> <a class="sectref" href="openssl-rand.html">3.2 rand  </A>
284
 
<b class="navlabel">Up:</b> <a class="sectref" href="openssl.html">3 OpenSSL  </A>
285
 
<b class="navlabel">Next:</b> <a class="sectref" href="openssl-context.html">3.3.1 Context objects</A>
286
 
<hr>
287
 
<span class="release-info">Release 0.13.</span>
288
 
</DIV>
289
 
<!--End of Navigation Panel-->
290
 
 
291
 
</BODY>
292
 
</HTML>