title: Ignore "certificate unknown" alert
body: <p>I have the following simple Python script:</p>
  
  <pre><code>import socket
  import ssl
  
  if __name__ == "__main__":
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      s.bind("", 443)
      s.listen(1)
      (conn, addr) = s.accept()
      sslconn = ssl.wrap_socket(conn, server_side=True, certfile="server.crt", keyfile="server.key", cert_reqs=ssl.CERT_NONE)
  
      print 'Connection established'
      while True:
          data = sslconn.recv(1024)
          if not data: break
          print "Data received"
  
  
      sslconn.close()
  </code></pre>
  
  <p>The files <code>server.crt</code> and <code>server.key</code> specify the public and private key of a self-signed certificate. If I connect to the host running this script using, say, Firefox, the script terminates with</p>
  
  <pre><code>ssl.SSLError: [Errno 1] _ssl.c:503: sslv3 alert certificate unknown
  </code></pre>
  
  <p>From what I gather, this comes from the client (say, Firefox) alerting the host that the certificate is invalid. That's fine, but why does it cause the script to terminate? Must I explicitly ignore the alert somehow?</p>