title: Python Error SSL: ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:726)
body: <p>i'm trying to get the SNI from a (IP, destport 443) with python 2.7.15 and i'm using the last version of OpenSSL and the ssl module.</p>
  
  <p>Here there is my code: </p>
  
  <pre><code>import OpenSSL as OSsl #This two modules are imported for the only purpose of getting the SNI using function defined by us down here getSNI
  import ssl
  
  
  
  ip = "52.85.25.17"
  dport = "443"
  
  
  #With this function we get the Server Name Identification for the trasmissions with Secure Socket Layer identified by the port 443. We only care about the destinationIP and the destinationPort
  
  def getSNI(ip, dport):
      if dport != "443":
          commonName = "Not SSL"
          print commonName
      else:   
          server_certificate = ssl.get_server_certificate((ip, dport))
  
          x509 = OSsl.crypto.load_certificate(OSsl.crypto.FILETYPE_PEM, server_certificate) #x509 is referred to the standard used for PKI (Public Key Infrastructure) used in this case for ciphering our informations about certificate
  
  #FILETYPE_PEM serializes data to a Base64-Encoded
  
      #getting the informations about Certificate
  
          certInfo = x509.get_subject()
          commonName = certInfo.commonName
          print (commonName) 
      return commonName
  
  
  getSNI(ip,dport)
  </code></pre>
  
  <p>This works, but for the address specified (in the snippet of code i posted here) I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "getSNI.py", line 31, in &lt;module&gt;
      getSNI(ip,dport)
    File "getSNI.py", line 17, in getSNI
      server_certificate = ssl.get_server_certificate((ip, dport))
    File "/usr/lib/python2.7/ssl.py", line 1023, in get_server_certificate
      with closing(context.wrap_socket(sock)) as sslsock:
    File "/usr/lib/python2.7/ssl.py", line 369, in wrap_socket
      _context=self)
    File "/usr/lib/python2.7/ssl.py", line 617, in __init__
      self.do_handshake()
    File "/usr/lib/python2.7/ssl.py", line 846, in do_handshake
      self._sslobj.do_handshake()
  ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:726)
  </code></pre>
  
  <p>I have all modules and packages upgraded, i read a lot of issues about this topic and i don't know how to solve this problem</p>
  
  <p>Edit1: Executing whois I found that this IpAddress is connected to Amazon, so are there any particular issues about Amazon and SNI?</p>