title: HTTPS connection using PEM Certificate
body: <p>I'm trying to POST HTTPS requests using a PEM certificate like following: </p>
  
  <pre><code>import httplib  
  CERT_FILE = '/path/certif.pem'
  conn = httplib.HTTPSConnection('10.10.10.10','443', cert_file =CERT_FILE)   
  conn.request("POST", "/") 
  response = conn.getresponse()       
  print response.status, response.reason
  conn.close()
  </code></pre>
  
  <p>I have the following error:</p>
  
  <pre><code>Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/lib/python2.6/httplib.py", line 914, in request
  self._send_request(method, url, body, headers)
  File "/usr/lib/python2.6/httplib.py", line 951, in _send_request
  self.endheaders()
  File "/usr/lib/python2.6/httplib.py", line 908, in endheaders
  self._send_output()
  File "/usr/lib/python2.6/httplib.py", line 780, in _send_output
  self.send(msg)
  File "/usr/lib/python2.6/httplib.py", line 739, in send
  self.connect()
  File "/usr/lib/python2.6/httplib.py", line 1116, in connect
  self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
  File "/usr/lib/python2.6/ssl.py", line 338, in wrap_socket
  suppress_ragged_eofs=suppress_ragged_eofs)
  File "/usr/lib/python2.6/ssl.py", line 118, in __init__
  cert_reqs, ssl_version, ca_certs)
  ssl.SSLError: [Errno 336265225] _ssl.c:339: error:140B0009:SSL       
  routines:**SSL_CTX_use_PrivateKey_file**:PEM lib
  </code></pre>
  
  <p>When I remove the cert_file from httplib, I've the following response:</p>
  
  <pre><code>200 ok
  </code></pre>
  
  <p>When I add the Authentication header (like advised by MattH) with empty post payload, it works also.</p>
  
  <p>However, when I put the good request with the Path, the Body and the Header, like following (I simplified them...)</p>
  
  <pre><code>body = '&lt;S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"&gt;blablabla&lt;/S:Envelope&gt;'
  URLprov = "/syncaxis2/services/XXXsyncService"
  auth_header = 'Basic %s' %  (":".join(["xxx","xxxxx"]).encode('Base64').strip('\r\n'))
  conn.request("POST",URLprov,body,{'Authenticate':auth_header})
  </code></pre>
  
  <p>I have 401 Unauthorized response !</p>
  
  <p>As you can see, first, I'm asked to provide the PrivateKey ! why did I need the PrivateKey if I'm a client ? then, when I remove the PrivateKey and the certificate, and put the Path/Body/headers I have 401 Unauthorized error with the message WWW-Authenticate: Basic realm="SYNCNB Server Realm".</p>
  
  <p>Could any one explain this issue? Is there another way to send HTTPS request using a certificate in Python?</p>