title: Server Side SSL using Diffie-Hellman in Python
body: <p>I'm trying to set up a socket using Diffie-Hellman SSL, but can't seem find any documentation on how to do this. I notice that SSLContext in Python 3.3+ supports load_dh_params and set_ecdh_curve which suggests that using DH is possible.</p>
  
  <p>I'm fairly new to using SSL so perhaps missing something obvious, but here's the code I'm using:</p>
  
  <pre><code>sock = socket.socket()
  sock.bind((HOST, PORT))
  sock.listen()
  context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS)
  context.set_ecdh_curve('prime256v1')
  ssock, address = self._server.accept()
  ssock= context.wrap_socket(ssock, server_side=True)
  </code></pre>
  
  <p>When using this code, I get the error:</p>
  
  <p>ssl.SSLError: [SSL: NO_SHARED_CIPHER] no shared cipher</p>
  
  <p>I've tried setting the ciphers like the following:</p>
  
  <pre><code>context.set_ciphers('ECDHE-RSA-AES256-GCM-SHA384')
  </code></pre>
  
  <p>but all the ciphers I've tried still throw up the same exception.</p>
  
  <p>If anyone could point out where I'm going wrong or provide a working example of using DH SSL, it'd be much appreciated!</p>