title: How to get the server's selected TLS verison in python ssl
body: <p>I am using python 3.6.5 and Windows 10. I need to get the TLS version that the server selected (i.e. the one that will be used for the rest of the handshake and NOT the client's offered version). I did this:</p>
  
  <pre><code>import socket, ssl
  
  context =  context = ssl.create_default_context()
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  domain = 'google.com'
  sslSocket = context.wrap_socket(s, server_hostname = domain)
  sslSocket.connect((domain, 443))
  print('the selected version by the server: ', sslSocket.cipher()[1])
  print("success")
  sslSocket.close()
  </code></pre>
  
  <p>But the output is:</p>
  
  <pre><code>the selected version by the server:  TLSv1/SSLv3
  success
  </code></pre>
  
  <p>I need accurate version. i.e, in a connection to <code>google.com</code>, it is <code>TLS 1.2</code> as the browser shows. How can I get accurate version in my code?</p>