cpython: 16c86a6bdbe2 (original) (raw)

--- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -867,10 +867,10 @@ SSL sockets also have the following addi .. method:: SSLSocket.selected_npn_protocol()

@@ -882,6 +882,16 @@ SSL sockets also have the following addi returned socket should always be used for further communication with the other side of the connection, rather than the original socket. +.. method:: SSLSocket.version() +

.. attribute:: SSLSocket.context The :class:SSLContext object this SSL socket is tied to. If the SSL

--- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -862,6 +862,15 @@ class SSLSocket(socket): return None return self._sslobj.tls_unique_cb()

+ def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE,

--- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -1904,7 +1904,8 @@ else: 'compression': s.compression(), 'cipher': s.cipher(), 'peercert': s.getpeercert(),

@@ -1912,6 +1913,13 @@ else: def try_protocol_combo(server_protocol, client_protocol, expect_success, certsreqs=None, server_options=0, client_options=0):

@@ -1941,8 +1949,8 @@ else: ctx.load_cert_chain(CERTFILE) ctx.load_verify_locations(CERTFILE) try:

@@ -1957,6 +1965,10 @@ else: "Client protocol %s succeeded with server protocol %s!" % (ssl.get_protocol_name(client_protocol), ssl.get_protocol_name(server_protocol)))

class ThreadedTests(unittest.TestCase): @@ -2186,17 +2198,17 @@ else: sys.stdout.write( " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n" % str(x))

# Server with specific SSL options try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False, @@ -2213,9 +2225,9 @@ else: """Connecting to an SSLv3 server with various client options""" if support.verbose: sys.stdout.write("\n")

@@ -2223,7 +2235,7 @@ else: try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False) if no_sslv2_implies_sslv3_hello(): # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs

@skip_if_broken_ubuntu_ssl @@ -2231,9 +2243,9 @@ else: """Connecting to a TLSv1 server with various client options""" if support.verbose: sys.stdout.write("\n")

@@ -2248,14 +2260,14 @@ else: Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n")

@@ -2268,7 +2280,7 @@ else: Testing against older TLS versions.""" if support.verbose: sys.stdout.write("\n")

@@ -2277,7 +2289,7 @@ else: try_protocol_combo(ssl.PROTOCOL_TLSv1_2, ssl.PROTOCOL_SSLv23, False, client_options=ssl.OP_NO_TLSv1_2)

@@ -2619,6 +2631,21 @@ else: s.connect((HOST, server.port)) self.assertIn("no shared cipher", str(server.conn_errors[0]))

+ @unittest.skipUnless(ssl.HAS_ECDH, "test requires ECDH-enabled OpenSSL") def test_default_ecdh_curve(self): # Issue #21015: elliptic curve-based Diffie Hellman key exchange

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -171,6 +171,7 @@ Windows -------

--- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -1384,6 +1384,18 @@ static PyObject *PySSL_cipher (PySSLSock return NULL; } +static PyObject *PySSL_version(PySSLSocket *self) +{

+

+} + #ifdef OPENSSL_NPN_NEGOTIATED static PyObject *PySSL_selected_npn_protocol(PySSLSocket *self) { const unsigned char *out; @@ -1907,6 +1919,7 @@ static PyMethodDef PySSLMethods[] = { {"peer_certificate", (PyCFunction)PySSL_peercert, METH_VARARGS, PySSL_peercert_doc}, {"cipher", (PyCFunction)PySSL_cipher, METH_NOARGS},

#ifdef OPENSSL_NPN_NEGOTIATED {"selected_npn_protocol", (PyCFunction)PySSL_selected_npn_protocol, METH_NOARGS}, #endif