title: Verify Peer in python
body: <p>I am trying to create a socket connection using python.</p>
  
  <p>Here is my python code...</p>
  
  <pre><code>socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  socket.settimeout(config['timeout'])
  self.socket.connect((config['host'], config['port']))
  
  self.ssl = ssl.wrap_socket(
      self.socket,
      certfile=config['certificate'],
      keyfile=config['key']
  )
  </code></pre>
  
  <p>It didn't work as remote server's certificate seems to be self-signed or missing from trust store. I am new to python and could not figure out how to disable verify_peer in python so connection could work. </p>
  
  <p>I have working code in php...</p>
  
  <pre><code>$context = stream_context_create([
      'ssl' =&gt; [
          'verify_peer' =&gt; false,
          'local_cert' =&gt; $config['certificate'],
          'local_pk' =&gt; $config['key']
      ]
  ]);
  
  $socket = stream_socket_client(
      'ssl://secure.test.com:700',
      $errno, $errstr, $config['timeout'],
      STREAM_CLIENT_CONNECT, $context
  );
  </code></pre>
  
  <p>Setting <code>'verify_peer' =&gt; false</code> helps to establish the connection. How can i do something like that in python?  </p>
  
  <p>openssl debug</p>
  
  <pre><code>openssl s_client -connect secure.test.com:700
  
  verify error:num=20:unable to get local issuer certificate
  verify return:1
  
  verify error:num=21:unable to verify the first certificate
  verify return:1
  </code></pre>
  
  <p>Please help and suggest. Thanks</p>