您可以使用disable_ssl_certificate_validation
忽略证书验证。请检查下面的示例。但是,由于以下错误,它不适用于Python 3.x。因此,您需要Python33\Lib\site-packages\httplib2\__init__.py
按照此问题的评论中的建议进行更新。
当 disable_ssl_certificate_validation = True 时 HTTPS 请求不起作用
import httplib2
h = httplib2.Http(".cache", disable_ssl_certificate_validation=True)
resp, content = h.request("https://github.com/", "GET")
Python 3.x 补丁:
diff --git a/__init__.py b/__init__.py
index 65f90ac..4495994 100644
--- a/__init__.py
+++ b/__init__.py
@@ -823,10 +823,13 @@ class HTTPSConnectionWithTimeout(http.client.HTTPSConnection):
context.load_cert_chain(cert_file, key_file)
if ca_certs:
context.load_verify_locations(ca_certs)
+ check_hostname = True
+ if disable_ssl_certificate_validation:
+ check_hostname = False
http.client.HTTPSConnection.__init__(
self, host, port=port, key_file=key_file,
cert_file=cert_file, timeout=timeout, context=context,
- check_hostname=True)
+ check_hostname=check_hostname)
SCHEME_TO_CONNECTION = {