Merge pull request #365 from rachmadaniHaryono/feature/custom-ca-certs

new: dev: use custom ca certs
This commit is contained in:
Mischievous Meerkat 2019-03-26 04:48:43 +05:30 committed by GitHub
commit 6e9da9bece
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

16
buku
View File

@ -2547,18 +2547,19 @@ class BukuDb:
if MYPROXY is None:
gen_headers()
ca_certs = os.getenv('BUKU_CA_CERTS', default=certifi.where())
if MYPROXY:
manager = urllib3.ProxyManager(
MYPROXY,
num_pools=1,
headers=MYHEADERS,
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where())
ca_certs=ca_certs)
else:
manager = urllib3.PoolManager(num_pools=1,
headers={'User-Agent': USER_AGENT},
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where())
ca_certs=ca_certs)
try:
r = manager.request(
@ -3392,17 +3393,17 @@ def get_PoolManager():
ProxyManager or PoolManager
ProxyManager if https_proxy is defined, PoolManager otherwise.
"""
ca_certs = os.getenv('BUKU_CA_CERTS', default=certifi.where())
if MYPROXY:
return urllib3.ProxyManager(MYPROXY, num_pools=1, headers=MYHEADERS, timeout=15,
cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
cert_reqs='CERT_REQUIRED', ca_certs=ca_certs)
return urllib3.PoolManager(
num_pools=1,
headers=MYHEADERS,
timeout=15,
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where())
ca_certs=ca_certs)
def network_handler(url, http_head=False):
@ -4224,19 +4225,20 @@ def check_upstream_release():
if MYPROXY is None:
gen_headers()
ca_certs = os.getenv('BUKU_CA_CERTS', default=certifi.where())
if MYPROXY:
manager = urllib3.ProxyManager(
MYPROXY,
num_pools=1,
headers=MYHEADERS,
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where()
ca_certs=ca_certs
)
else:
manager = urllib3.PoolManager(num_pools=1,
headers={'User-Agent': USER_AGENT},
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where())
ca_certs=ca_certs)
try:
r = manager.request(