equal
deleted
inserted
replaced
76 if ssl: |
76 if ssl: |
77 wrap_socket = ssl.wrap_socket |
77 wrap_socket = ssl.wrap_socket |
78 CERT_NONE = ssl.CERT_NONE |
78 CERT_NONE = ssl.CERT_NONE |
79 CERT_OPTIONAL = ssl.CERT_OPTIONAL |
79 CERT_OPTIONAL = ssl.CERT_OPTIONAL |
80 CERT_REQUIRED = ssl.CERT_REQUIRED |
80 CERT_REQUIRED = ssl.CERT_REQUIRED |
81 PROTOCOL_SSLv2 = ssl.PROTOCOL_SSLv2 |
|
82 PROTOCOL_SSLv3 = ssl.PROTOCOL_SSLv3 |
|
83 PROTOCOL_SSLv23 = ssl.PROTOCOL_SSLv23 |
|
84 PROTOCOL_TLSv1 = ssl.PROTOCOL_TLSv1 |
|
85 else: |
81 else: |
86 class FakeSocket(httplib.FakeSocket): |
82 class FakeSocket(httplib.FakeSocket): |
87 """Socket wrapper that supports SSL. |
83 """Socket wrapper that supports SSL. |
88 """ |
84 """ |
89 # backport the behavior from Python 2.6, which is to busy wait |
85 # backport the behavior from Python 2.6, which is to busy wait |
103 if x.args[0] == socket.SSL_ERROR_WANT_READ: |
99 if x.args[0] == socket.SSL_ERROR_WANT_READ: |
104 continue |
100 continue |
105 else: |
101 else: |
106 raise x |
102 raise x |
107 |
103 |
108 PROTOCOL_SSLv2 = 0 |
104 _PROTOCOL_SSLv23 = 2 |
109 PROTOCOL_SSLv3 = 1 |
|
110 PROTOCOL_SSLv23 = 2 |
|
111 PROTOCOL_TLSv1 = 3 |
|
112 |
105 |
113 CERT_NONE = 0 |
106 CERT_NONE = 0 |
114 CERT_OPTIONAL = 1 |
107 CERT_OPTIONAL = 1 |
115 CERT_REQUIRED = 2 |
108 CERT_REQUIRED = 2 |
116 |
109 |
117 def wrap_socket(sock, keyfile=None, certfile=None, |
110 def wrap_socket(sock, keyfile=None, certfile=None, |
118 server_side=False, cert_reqs=CERT_NONE, |
111 server_side=False, cert_reqs=CERT_NONE, |
119 ssl_version=PROTOCOL_SSLv23, ca_certs=None, |
112 ssl_version=_PROTOCOL_SSLv23, ca_certs=None, |
120 do_handshake_on_connect=True, |
113 do_handshake_on_connect=True, |
121 suppress_ragged_eofs=True): |
114 suppress_ragged_eofs=True): |
122 if cert_reqs != CERT_NONE and ca_certs: |
115 if cert_reqs != CERT_NONE and ca_certs: |
123 raise CertificateValidationUnsupported( |
116 raise CertificateValidationUnsupported( |
124 'SSL certificate validation requires the ssl module' |
117 'SSL certificate validation requires the ssl module' |