Merge pull request #518 from FollieHiyuki/master
Use system ca-certificates if it exists on Linux
This commit is contained in:
commit
a51f226bf7
17
buku
17
buku
@ -45,7 +45,6 @@ import time
|
|||||||
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import certifi
|
|
||||||
import urllib3
|
import urllib3
|
||||||
from urllib3.exceptions import LocationParseError
|
from urllib3.exceptions import LocationParseError
|
||||||
from urllib3.util import parse_url, make_headers, Retry
|
from urllib3.util import parse_url, make_headers, Retry
|
||||||
@ -105,6 +104,16 @@ LOGGER = logging.getLogger()
|
|||||||
LOGDBG = LOGGER.debug
|
LOGDBG = LOGGER.debug
|
||||||
LOGERR = LOGGER.error
|
LOGERR = LOGGER.error
|
||||||
|
|
||||||
|
# Define the default path to ca-certificates
|
||||||
|
# In Linux distros with openssl, it is /etc/ssl/certs/ca-certificates.crt
|
||||||
|
# Fall back to use `certifi` otherwise
|
||||||
|
try:
|
||||||
|
os.path.isfile('/etc/ssl/certs/ca-certificates.crt')
|
||||||
|
CA_CERTS = '/etc/ssl/certs/ca-certificates.crt'
|
||||||
|
except Exception:
|
||||||
|
import certifi
|
||||||
|
CA_CERTS = certifi.where()
|
||||||
|
|
||||||
|
|
||||||
class BukuCrypt:
|
class BukuCrypt:
|
||||||
"""Class to handle encryption and decryption of
|
"""Class to handle encryption and decryption of
|
||||||
@ -2656,7 +2665,7 @@ class BukuDb:
|
|||||||
if MYPROXY is None:
|
if MYPROXY is None:
|
||||||
gen_headers()
|
gen_headers()
|
||||||
|
|
||||||
ca_certs = os.getenv('BUKU_CA_CERTS', default=certifi.where())
|
ca_certs = os.getenv('BUKU_CA_CERTS', default=CA_CERTS)
|
||||||
if MYPROXY:
|
if MYPROXY:
|
||||||
manager = urllib3.ProxyManager(
|
manager = urllib3.ProxyManager(
|
||||||
MYPROXY,
|
MYPROXY,
|
||||||
@ -3628,7 +3637,7 @@ def get_PoolManager():
|
|||||||
ProxyManager or PoolManager
|
ProxyManager or PoolManager
|
||||||
ProxyManager if https_proxy is defined, PoolManager otherwise.
|
ProxyManager if https_proxy is defined, PoolManager otherwise.
|
||||||
"""
|
"""
|
||||||
ca_certs = os.getenv('BUKU_CA_CERTS', default=certifi.where())
|
ca_certs = os.getenv('BUKU_CA_CERTS', default=CA_CERTS)
|
||||||
if MYPROXY:
|
if MYPROXY:
|
||||||
return urllib3.ProxyManager(MYPROXY, num_pools=1, headers=MYHEADERS, timeout=15,
|
return urllib3.ProxyManager(MYPROXY, num_pools=1, headers=MYHEADERS, timeout=15,
|
||||||
cert_reqs='CERT_REQUIRED', ca_certs=ca_certs)
|
cert_reqs='CERT_REQUIRED', ca_certs=ca_certs)
|
||||||
@ -4523,7 +4532,7 @@ def check_upstream_release():
|
|||||||
if MYPROXY is None:
|
if MYPROXY is None:
|
||||||
gen_headers()
|
gen_headers()
|
||||||
|
|
||||||
ca_certs = os.getenv('BUKU_CA_CERTS', default=certifi.where())
|
ca_certs = os.getenv('BUKU_CA_CERTS', default=CA_CERTS)
|
||||||
if MYPROXY:
|
if MYPROXY:
|
||||||
manager = urllib3.ProxyManager(
|
manager = urllib3.ProxyManager(
|
||||||
MYPROXY,
|
MYPROXY,
|
||||||
|
2
setup.py
2
setup.py
@ -74,7 +74,6 @@ setup(
|
|||||||
py_modules=['buku'],
|
py_modules=['buku'],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'beautifulsoup4>=4.4.1',
|
'beautifulsoup4>=4.4.1',
|
||||||
'certifi',
|
|
||||||
'cryptography>=1.2.3',
|
'cryptography>=1.2.3',
|
||||||
'urllib3>=1.23',
|
'urllib3>=1.23',
|
||||||
'html5lib>=1.0.1',
|
'html5lib>=1.0.1',
|
||||||
@ -85,6 +84,7 @@ setup(
|
|||||||
'console_scripts': ['buku=buku:main', 'bukuserver=bukuserver.server:cli']
|
'console_scripts': ['buku=buku:main', 'bukuserver=bukuserver.server:cli']
|
||||||
},
|
},
|
||||||
extras_require={
|
extras_require={
|
||||||
|
'ca-certificates': ['certifi'],
|
||||||
'tests': tests_require + server_require,
|
'tests': tests_require + server_require,
|
||||||
'server': server_require,
|
'server': server_require,
|
||||||
'packaging': ['twine>=1.11.0']
|
'packaging': ['twine>=1.11.0']
|
||||||
|
Loading…
Reference in New Issue
Block a user