title: ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
body: <p>I am trying to create TLS connection with a server. My simple script is below. However, when I run it, I get this error:</p>
  
  <pre><code> Traceback (most recent call last):
    File "tls_client.py", line 28, in &lt;module&gt;
      sslSocket.connect((domain, 443))
    File "C:\Python36\lib\ssl.py", line 1100, in connect
      self._real_connect(addr, False)
    File "C:\Python36\lib\ssl.py", line 1091, in _real_connect
      self.do_handshake()
    File "C:\Python36\lib\ssl.py", line 1068, in do_handshake
      self._sslobj.do_handshake()
    File "C:\Python36\lib\ssl.py", line 689, in do_handshake
      self._sslobj.do_handshake()
  ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
  </code></pre>
  
  <p>The script:</p>
  
  <pre><code>   import socket, ssl
      context = ssl.SSLContext(protocol = ssl.PROTOCOL_TLS_CLIENT)
      context.set_ciphers('ECDHE-RSA-AES128-GCM-SHA256')
      context.verify_mode = ssl.CERT_OPTIONAL
      s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      sslSocket = context.wrap_socket(s, server_hostname = 'www.google.com')
      sslSocket.connect((domain, 443))
  </code></pre>
  
  <p>What is the cause of the problem? I tried couple of websites like <code>www.verisign.com</code> but I also get the same error.</p>
  
  <p><strong>EDIT:</strong>
  I do not want to turn verify_mode off. I need it on. I think <code>google.com</code> and <code>verisign.com</code> have verifiable certificates.</p>
  
  <p><strong>EDIT 2:</strong>
  Based on a solution in the <a href="https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error">link</a> provided:
  I run pip install certifi
  Then tried to run this command in Windows command but get an error:</p>
  
  <pre><code>&gt;/Applications/Python\ 3.6/Install\ Certificates.comman
  '/Applications/Python\' is not recognized as an internal or external command,
  operable program or batch file.
  </code></pre>