I have a problem getting html page from https server. Access to the resource is secured with client certificate verification (in a browser I must choose proper certificate to access page).
I am trying to use python's http.client
library like this:
import http.client
conn = http.client.HTTPSConnection('example.com', 443, key_file = 'tmp/private.pem', cert_file = 'tmp/public.pem')
conn.set_debuglevel(0)
conn.request('GET', '/index.htm')
result = conn.getresponse()
if result.status != http.client.ACCEPTED:
pass
print(result.status, result.reason)
conn.close()
As an output from this program I get: 403 Forbidden
. What am I doing wrong?
Note that I can access this resource directly through browser. The private and public keys are extracted from pkcs12 file exported from that browser with openssl commands (openssl pkcs12 -nocerts -nodes -in cert.p12 -out private.pem
and openssl pkcs12 -nokeys -in cert.p12 -out public.pem
)