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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module gdata.tlslite.integration.HTTPTLSConnection</title>
</head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="gdata.html"><font color="#ffffff">gdata</font></a>.<a href="gdata.tlslite.html"><font color="#ffffff">tlslite</font></a>.<a href="gdata.tlslite.integration.html"><font color="#ffffff">integration</font></a>.HTTPTLSConnection</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/afshar/wrk/gdata-python-client/src/gdata/tlslite/integration/HTTPTLSConnection.py">/home/afshar/wrk/gdata-python-client/src/gdata/tlslite/integration/HTTPTLSConnection.py</a></font></td></tr></table>
<p><tt>TLS Lite + httplib.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="httplib.html">httplib</a><br>
</td><td width="25%" valign=top><a href="socket.html">socket</a><br>
</td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ee77aa">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
<td width="100%"><dl>
<dt><font face="helvetica, arial"><a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a>
</font></dt><dd>
<dl>
<dt><font face="helvetica, arial"><a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPTLSConnection">HTTPTLSConnection</a>(<a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a>, <a href="gdata.tlslite.integration.ClientHelper.html#ClientHelper">gdata.tlslite.integration.ClientHelper.ClientHelper</a>)
</font></dt></dl>
</dd>
</dl>
</dd>
</dl>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="HTTPBaseTLSConnection">class <strong>HTTPBaseTLSConnection</strong></a>(<a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>This abstract class provides a framework for adding TLS support<br>
to httplib.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%">Methods defined here:<br>
<dl><dt><a name="HTTPBaseTLSConnection-__init__"><strong>__init__</strong></a>(self, host, port<font color="#909090">=None</font>, strict<font color="#909090">=None</font>)</dt></dl>
<dl><dt><a name="HTTPBaseTLSConnection-connect"><strong>connect</strong></a>(self)</dt></dl>
<hr>
Data and other attributes defined here:<br>
<dl><dt><strong>default_port</strong> = 443</dl>
<hr>
Methods inherited from <a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a>:<br>
<dl><dt><a name="HTTPBaseTLSConnection-close"><strong>close</strong></a>(self)</dt><dd><tt>Close the connection to the HTTP server.</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-endheaders"><strong>endheaders</strong></a>(self)</dt><dd><tt>Indicate that the last header line has been sent to the server.</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-getresponse"><strong>getresponse</strong></a>(self)</dt><dd><tt>Get the response from the server.</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-putheader"><strong>putheader</strong></a>(self, header, value)</dt><dd><tt>Send a request header line to the server.<br>
<br>
For example: h.<a href="#HTTPBaseTLSConnection-putheader">putheader</a>('Accept', 'text/html')</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-putrequest"><strong>putrequest</strong></a>(self, method, url, skip_host<font color="#909090">=0</font>, skip_accept_encoding<font color="#909090">=0</font>)</dt><dd><tt>Send a request to the server.<br>
<br>
`method' specifies an HTTP request method, e.g. 'GET'.<br>
`url' specifies the object being requested, e.g. '/index.html'.<br>
`skip_host' if True does not add automatically a 'Host:' header<br>
`skip_accept_encoding' if True does not add automatically an<br>
'Accept-Encoding:' header</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-request"><strong>request</strong></a>(self, method, url, body<font color="#909090">=None</font>, headers<font color="#909090">={}</font>)</dt><dd><tt>Send a complete request to the server.</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-send"><strong>send</strong></a>(self, str)</dt><dd><tt>Send `str' to the server.</tt></dd></dl>
<dl><dt><a name="HTTPBaseTLSConnection-set_debuglevel"><strong>set_debuglevel</strong></a>(self, level)</dt></dl>
<hr>
Data and other attributes inherited from <a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a>:<br>
<dl><dt><strong>auto_open</strong> = 1</dl>
<dl><dt><strong>debuglevel</strong> = 0</dl>
<dl><dt><strong>response_class</strong> = <class httplib.HTTPResponse></dl>
<dl><dt><strong>strict</strong> = 0</dl>
</td></tr></table> <p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom> <br>
<font color="#000000" face="helvetica, arial"><a name="HTTPTLSConnection">class <strong>HTTPTLSConnection</strong></a>(<a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a>, <a href="gdata.tlslite.integration.ClientHelper.html#ClientHelper">gdata.tlslite.integration.ClientHelper.ClientHelper</a>)</font></td></tr>
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
<td colspan=2><tt>This class extends L{<a href="#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a>} to support the<br>
common types of handshaking.<br> </tt></td></tr>
<tr><td> </td>
<td width="100%"><dl><dt>Method resolution order:</dt>
<dd><a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPTLSConnection">HTTPTLSConnection</a></dd>
<dd><a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a></dd>
<dd><a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a></dd>
<dd><a href="gdata.tlslite.integration.ClientHelper.html#ClientHelper">gdata.tlslite.integration.ClientHelper.ClientHelper</a></dd>
</dl>
<hr>
Methods defined here:<br>
<dl><dt><a name="HTTPTLSConnection-__init__"><strong>__init__</strong></a>(self, host, port<font color="#909090">=None</font>, username<font color="#909090">=None</font>, password<font color="#909090">=None</font>, sharedKey<font color="#909090">=None</font>, certChain<font color="#909090">=None</font>, privateKey<font color="#909090">=None</font>, cryptoID<font color="#909090">=None</font>, protocol<font color="#909090">=None</font>, x509Fingerprint<font color="#909090">=None</font>, x509TrustList<font color="#909090">=None</font>, x509CommonName<font color="#909090">=None</font>, settings<font color="#909090">=None</font>)</dt><dd><tt>Create a new <a href="#HTTPTLSConnection">HTTPTLSConnection</a>.<br>
<br>
For client authentication, use one of these argument<br>
combinations:<br>
- username, password (SRP)<br>
- username, sharedKey (shared-key)<br>
- certChain, privateKey (certificate)<br>
<br>
For server authentication, you can either rely on the<br>
implicit mutual authentication performed by SRP or<br>
shared-keys, or you can do certificate-based server<br>
authentication with one of these argument combinations:<br>
- cryptoID[, protocol] (requires cryptoIDlib)<br>
- x509Fingerprint<br>
- x509TrustList[, x509CommonName] (requires cryptlib_py)<br>
<br>
Certificate-based server authentication is compatible with<br>
SRP or certificate-based client authentication. It is<br>
not compatible with shared-keys.<br>
<br>
The constructor does not perform the TLS handshake itself, but<br>
simply stores these arguments for later. The handshake is<br>
performed only when this class needs to connect with the<br>
server. Thus you should be prepared to handle TLS-specific<br>
exceptions when calling methods inherited from<br>
L{httplib.<a href="httplib.html#HTTPConnection">HTTPConnection</a>} such as <a href="#HTTPTLSConnection-request">request</a>(), <a href="#HTTPTLSConnection-connect">connect</a>(), and<br>
<a href="#HTTPTLSConnection-send">send</a>(). See the client handshake functions in<br>
L{tlslite.TLSConnection.TLSConnection} for details on which<br>
exceptions might be raised.<br>
<br>
@type host: str<br>
@param host: Server to connect to.<br>
<br>
@type port: int<br>
@param port: Port to connect to.<br>
<br>
@type username: str<br>
@param username: SRP or shared-key username. Requires the<br>
'password' or 'sharedKey' argument.<br>
<br>
@type password: str<br>
@param password: SRP password for mutual authentication.<br>
Requires the 'username' argument.<br>
<br>
@type sharedKey: str<br>
@param sharedKey: Shared key for mutual authentication.<br>
Requires the 'username' argument.<br>
<br>
@type certChain: L{tlslite.X509CertChain.X509CertChain} or<br>
L{cryptoIDlib.CertChain.CertChain}<br>
@param certChain: Certificate chain for client authentication.<br>
Requires the 'privateKey' argument. Excludes the SRP or<br>
shared-key related arguments.<br>
<br>
@type privateKey: L{tlslite.utils.RSAKey.RSAKey}<br>
@param privateKey: Private key for client authentication.<br>
Requires the 'certChain' argument. Excludes the SRP or<br>
shared-key related arguments.<br>
<br>
@type cryptoID: str<br>
@param cryptoID: cryptoID for server authentication. Mutually<br>
exclusive with the 'x509...' arguments.<br>
<br>
@type protocol: str<br>
@param protocol: cryptoID protocol URI for server<br>
authentication. Requires the 'cryptoID' argument.<br>
<br>
@type x509Fingerprint: str<br>
@param x509Fingerprint: Hex-encoded X.509 fingerprint for<br>
server authentication. Mutually exclusive with the 'cryptoID'<br>
and 'x509TrustList' arguments.<br>
<br>
@type x509TrustList: list of L{tlslite.X509.X509}<br>
@param x509TrustList: A list of trusted root certificates. The<br>
other party must present a certificate chain which extends to<br>
one of these root certificates. The cryptlib_py module must be<br>
installed to use this parameter. Mutually exclusive with the<br>
'cryptoID' and 'x509Fingerprint' arguments.<br>
<br>
@type x509CommonName: str<br>
@param x509CommonName: The end-entity certificate's 'CN' field<br>
must match this value. For a web server, this is typically a<br>
server name such as 'www.amazon.com'. Mutually exclusive with<br>
the 'cryptoID' and 'x509Fingerprint' arguments. Requires the<br>
'x509TrustList' argument.<br>
<br>
@type settings: L{tlslite.HandshakeSettings.HandshakeSettings}<br>
@param settings: Various settings which can be used to control<br>
the ciphersuites, certificate types, and SSL/TLS versions<br>
offered by the client.</tt></dd></dl>
<hr>
Methods inherited from <a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a>:<br>
<dl><dt><a name="HTTPTLSConnection-connect"><strong>connect</strong></a>(self)</dt></dl>
<hr>
Data and other attributes inherited from <a href="gdata.tlslite.integration.HTTPTLSConnection.html#HTTPBaseTLSConnection">HTTPBaseTLSConnection</a>:<br>
<dl><dt><strong>default_port</strong> = 443</dl>
<hr>
Methods inherited from <a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a>:<br>
<dl><dt><a name="HTTPTLSConnection-close"><strong>close</strong></a>(self)</dt><dd><tt>Close the connection to the HTTP server.</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-endheaders"><strong>endheaders</strong></a>(self)</dt><dd><tt>Indicate that the last header line has been sent to the server.</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-getresponse"><strong>getresponse</strong></a>(self)</dt><dd><tt>Get the response from the server.</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-putheader"><strong>putheader</strong></a>(self, header, value)</dt><dd><tt>Send a request header line to the server.<br>
<br>
For example: h.<a href="#HTTPTLSConnection-putheader">putheader</a>('Accept', 'text/html')</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-putrequest"><strong>putrequest</strong></a>(self, method, url, skip_host<font color="#909090">=0</font>, skip_accept_encoding<font color="#909090">=0</font>)</dt><dd><tt>Send a request to the server.<br>
<br>
`method' specifies an HTTP request method, e.g. 'GET'.<br>
`url' specifies the object being requested, e.g. '/index.html'.<br>
`skip_host' if True does not add automatically a 'Host:' header<br>
`skip_accept_encoding' if True does not add automatically an<br>
'Accept-Encoding:' header</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-request"><strong>request</strong></a>(self, method, url, body<font color="#909090">=None</font>, headers<font color="#909090">={}</font>)</dt><dd><tt>Send a complete request to the server.</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-send"><strong>send</strong></a>(self, str)</dt><dd><tt>Send `str' to the server.</tt></dd></dl>
<dl><dt><a name="HTTPTLSConnection-set_debuglevel"><strong>set_debuglevel</strong></a>(self, level)</dt></dl>
<hr>
Data and other attributes inherited from <a href="httplib.html#HTTPConnection">httplib.HTTPConnection</a>:<br>
<dl><dt><strong>auto_open</strong> = 1</dl>
<dl><dt><strong>debuglevel</strong> = 0</dl>
<dl><dt><strong>response_class</strong> = <class httplib.HTTPResponse></dl>
<dl><dt><strong>strict</strong> = 0</dl>
</td></tr></table></td></tr></table>
</body></html>
|