I am using python 2.7.10
request = urllib2.Request(url, data=urllib.urlencode(params))
f = urllib2.urlopen(request))
cause the following ex
When you access URL through browser, you browser becomes client and server becomes on which Web site is hosted. Now, since you have imported CA certificate for browser, that's why web site is opening without error in browser.
Now, when you open same website from your python script, client becomes your python script and it is not aware of this CA certificate. Python script do not use the Windows Certificate Store, so you will have to specify a CA certificate against which the certificate verification will be done.
So, you have tell explicitly to script regarding CA certificate which can as follow:
urllib2.urlopen("https://dinesh.com", cafile="test_cert.pem")
You can find the documentation here: urllib2.urlopen.
UPDATE
Snippet from the above link:
The optional
cafile
andcapath
parameters specify a set of trusted CA certificates for HTTPS requests.cafile
should point to a single file containing a bundle of CA certificates, whereascapath
should point to a directory of hashed certificate files. More information can be found in ssl.SSLContext.load_verify_locations().