title: How to set ciphers in ssl python socket
body: <p>I want to create my own list of ciphersuites using the cipher strings. The following code works if I put only one string in the <code>set_ciphers</code> function. But I want a customized list of ciphers. There is other format like: <code>ALL:!COMPLEMENTOFDEFAULT:!eNULL</code> but this does not do the purpose I need. I have a customized list of different ciphers that I can not combine using the second format. </p>
  
  <pre><code>import socket, ssl
  import pprint
  
  context = ssl.create_default_context()
  
  cipher = ['DHE-RSA-AES128-SHA', 'DHE-RSA-AES256-SHA', 'ECDHE-ECDSA-AES128-GCM-SHA256']
  context.set_ciphers(cipher)
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  domain = 'google.com'
  
  sslSocket = context.wrap_socket(s, server_hostname = domain)
  
  sslSocket.connect((domain, 443))
  sslSocket.close()
  print('closed')
  </code></pre>
  
  <p>The function <code>set_ciphers</code> can be found <a href="https://docs.python.org/3/library/ssl.html#ssl.SSLContext.set_ciphers" rel="nofollow noreferrer">here</a>.</p>