title: not able to verify ssl-certificate from client side using any of python requests, httplib/httplib2, urllib/urlib2
body: <p>this question is duplicate. but i am still asking because i am not finding any solution from given answers. so guys don't make it duplicate, instead help me to solve this problem.</p>
  
  <p>i am running my server as https using bottle(paste). when trying to access from java and postman , it's verifying correctly and response coming.</p>
  
  <p>versions used :
  python 2.7.13</p>
  
  <blockquote>
    <blockquote>
      <blockquote>
        <p>requests.<strong>version</strong>
        '2.11.1'
        import cryptography
        cryptography.<strong>version</strong>
        '2.1.3'
        import OpenSSL
        OpenSSL.<strong>version</strong>
        '17.3.0'</p>
      </blockquote>
    </blockquote>
  </blockquote>
  
  <p>but unfortunately when trying to access from python modules - it's throwing issue. ?</p>
  
  <pre><code>requests.post(url, verify=_certfile, proxies=proxies) #tried #failed to verify certificate
  
  urllib2.urlopen(url, data=data, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
          cafile=None, capath=None, cadefault=False, context=context)  #tried #failed to verify certificate
  
  import httplib2
  
  http = httplib2.Http(disable_ssl_certificate_validation=True)
  headers, content = http.request(url, "POST", body=data, headers=headers)#tried #failed to verify certificate
  
  httplib.HTTPSConnection(host='10.201.41.50', port=8018, key_file=key_file, cert_file=cert_file, strict=None, context=context) #tried #failed to verify certificate
  </code></pre>
  
  <p>and my server is running using paste server using bottle framework.</p>
  
  <pre><code>ssl_cxt = SSL.Context(SSL.SSLv23_METHOD)
  ...
  ...
  ssl_cxt.set_verify(SSL.VERIFY_PEER | SSL.VERIFY_FAIL_IF_NO_PEER_CERT, verify_cb)
  paste.httpserver.serve(app, host=IP, port=PORT, server_version=" ", ssl_context=ssl_cxt)
  </code></pre>
  
  <p>issues i am facing (different with each lib)</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "Continuum\Anaconda2\lib\site-packages\requests\api.py", line 70, in get
  return request('get', url, params=params, **kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\api.py", line 56, in request
  return session.request(method=method, url=url, **kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\sessions.py", line 475, in request
  resp = self.send(prep, **send_kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\sessions.py", line 596, in send
  r = adapter.send(request, **kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\adapters.py", line 497, in send
  raise SSLError(e, request=request)
  requests.exceptions.SSLError: unknown error (_ssl.c:2947)
  </code></pre>
  
  <p>============</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "Continuum\Anaconda2\lib\site-packages\requests\api.py", line 70, in get
  return request('get', url, params=params, **kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\api.py", line 56, in request
  return session.request(method=method, url=url, **kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\sessions.py", line 475, in request
  resp = self.send(prep, **send_kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\sessions.py", line 596, in send
  r = adapter.send(request, **kwargs)
  File "Continuum\Anaconda2\lib\site-packages\requests\adapters.py", line 497, in send
  raise SSLError(e, request=request)
  requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate 
  verify failed (_ssl.c:661)
  
    File "Continuum\Anaconda2\lib\httplib.py", line 1038, in endheaders
    self._send_output(message_body)
    File "Continuum\Anaconda2\lib\httplib.py", line 882, in _send_output
    self.send(msg)
    File "Continuum\Anaconda2\lib\httplib.py", line 844, in send
    self.connect()
    File "Continuum\Anaconda2\lib\httplib.py", line 1262, in connect
    self.sock = self._context.wrap_socket(self.sock,
    AttributeError: 'Context' object has no attribute 'wrap_socket'
  </code></pre>