title: "ssl.SSLError: ... No shared cipher" when trying to handle HTTPS requests webserver
body: <p>I'm trying to extend a web server I made to handle HTTPS requests via SSL.
  My prof said we should use <code>ssl.wrap_socket</code> and gave us the cipher to use.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>from socket import *
  import ssl
  
  serverSocket = socket(AF_INET, SOCK_STREAM)
  serverPort = 443
  serverSocket.bind(("", serverPort))
  serverSocket.listen(1)
  
  while True:
      print ('Ready to serve...')
      connectionSocket, addr = serverSocket.accept()
  
      connectionSocket = ssl.wrap_socket(connectionSocket,
                                  keyfile="./server.key",
                                  certfile="./server.pem",
                                  server_side=True,
                                  cert_reqs=ssl.CERT_NONE,
                                  ssl_version=ssl.PROTOCOL_SSLv23,
                                  ca_certs=None,
                                  do_handshake_on_connect=True,
                                  suppress_ragged_eofs=True,
                                  ciphers="AES128-SHA256")
  
      try:
          message =  (connectionSocket.recv(1024)).decode('utf-8')
          filename = message.split()[1]
  
          f = open(filename[1:],'rb')
          outputdata = f.read()
          f.close()
  
          connectionSocket.send(b'HTTP/1.1 200 OK\r\n\r\n')
          connectionSocket.send(outputdata)
          connectionSocket.send(b'\r\n')
  
          connectionSocket.shutdown(SHUT_RDWR)
          connectionSocket.close()
  
      except IOError:
          connectionSocket.send(b'HTTP/1.1 404 Not Found\r\n\r\n')
          connectionSocket.send(b'&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;404 Not Found&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;\r\n')
  
          connectionSocket.shutdown(SHUT_RDWR)
          connectionSocket.close()
  
  serverSocket.close()
  </code></pre>
  
  <p>I've tested this in the command line with the following code and it seems to work. It shows me the right info about the SSL sessions such as protocol, cipher, session-ID, Master-key and the contents of <code>index.html</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code>openssl s_client -connect localhost:443
  GET /index.html
  </code></pre>
  
  <p>For the next section of the assignment I have to put <code>"https://localhost:443/index.html"</code> into my browser, but my webserver crashes with this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>ssl.SSLError: [SSL: NO_SHARED_CIPHER] no shared cipher (_ssl.c:661)
  </code></pre>
  
  <p>What is wrong with my code?</p>