mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Rename tls_fingerprint to verify_fingerprint
This commit is contained in:
parent
5509868958
commit
c9c2a43f43
3 changed files with 14 additions and 12 deletions
|
|
@ -162,14 +162,14 @@ class DavSession(object):
|
|||
'''
|
||||
|
||||
def __init__(self, url, username='', password='', verify=True, auth=None,
|
||||
useragent=USERAGENT, tls_fingerprint=None, dav_header=None):
|
||||
useragent=USERAGENT, verify_fingerprint=None, dav_header=None):
|
||||
if username and not password:
|
||||
password = utils.get_password(username, url)
|
||||
|
||||
self._settings = {
|
||||
'verify': prepare_verify(verify),
|
||||
'auth': prepare_auth(auth, username, password),
|
||||
'tls_fingerprint': tls_fingerprint,
|
||||
'verify_fingerprint': verify_fingerprint,
|
||||
}
|
||||
self.useragent = useragent
|
||||
self.url = url.rstrip('/') + '/'
|
||||
|
|
@ -223,7 +223,7 @@ class DavStorage(Storage):
|
|||
:param password: Password for authentication.
|
||||
:param verify: Verify SSL certificate, default True. This can also be a
|
||||
local path to a self-signed SSL certificate.
|
||||
:param tls_fingerprint: Optional. SHA1 or MD5 fingerprint of the
|
||||
:param verify_fingerprint: Optional. SHA1 or MD5 fingerprint of the
|
||||
expected server certificate.
|
||||
:param auth: Optional. Either ``basic``, ``digest`` or ``guess``. Default
|
||||
``guess``. If you know yours, consider setting it explicitly for
|
||||
|
|
@ -251,14 +251,14 @@ class DavStorage(Storage):
|
|||
|
||||
def __init__(self, url, username='', password='', collection=None,
|
||||
verify=True, auth=None, useragent=USERAGENT,
|
||||
unsafe_href_chars='@', tls_fingerprint=None, **kwargs):
|
||||
unsafe_href_chars='@', verify_fingerprint=None, **kwargs):
|
||||
super(DavStorage, self).__init__(**kwargs)
|
||||
|
||||
url = url.rstrip('/') + '/'
|
||||
if collection is not None:
|
||||
url = utils.urlparse.urljoin(url, collection)
|
||||
self.session = DavSession(url, username, password, verify, auth,
|
||||
useragent, tls_fingerprint,
|
||||
useragent, verify_fingerprint,
|
||||
dav_header=self.dav_header)
|
||||
self.collection = collection
|
||||
self.unsafe_href_chars = unsafe_href_chars
|
||||
|
|
@ -273,7 +273,7 @@ class DavStorage(Storage):
|
|||
raise TypeError('collection argument must not be given.')
|
||||
discover_args, _ = utils.split_dict(kwargs, lambda key: key in (
|
||||
'username', 'password', 'verify', 'auth', 'useragent',
|
||||
'tls_fingerprint',
|
||||
'verify_fingerprint',
|
||||
))
|
||||
d = cls.discovery_class(DavSession(
|
||||
url=url, dav_header=cls.dav_header, **discover_args))
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class HttpStorage(Storage):
|
|||
:param password: Password for authentication.
|
||||
:param verify: Verify SSL certificate, default True. This can also be a
|
||||
local path to a self-signed SSL certificate.
|
||||
:param tls_fingerprint: Optional. SHA1 or MD5 fingerprint of the
|
||||
:param verify_fingerprint: Optional. SHA1 or MD5 fingerprint of the
|
||||
expected server certificate.
|
||||
:param auth: Optional. Either ``basic``, ``digest`` or ``guess``. Default
|
||||
``guess``. If you know yours, consider setting it explicitly for
|
||||
|
|
@ -84,7 +84,7 @@ class HttpStorage(Storage):
|
|||
|
||||
def __init__(self, url, username='', password='', collection=None,
|
||||
verify=True, auth=None, useragent=USERAGENT,
|
||||
tls_fingerprint=None, **kwargs):
|
||||
verify_fingerprint=None, **kwargs):
|
||||
super(HttpStorage, self).__init__(**kwargs)
|
||||
|
||||
if username and not password:
|
||||
|
|
@ -92,7 +92,7 @@ class HttpStorage(Storage):
|
|||
|
||||
self._settings = {
|
||||
'verify': prepare_verify(verify),
|
||||
'tls_fingerprint': tls_fingerprint,
|
||||
'verify_fingerprint': verify_fingerprint,
|
||||
'auth': prepare_auth(auth, username, password),
|
||||
'latin1_fallback': False
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,12 +194,14 @@ class _FingerprintAdapter(requests.adapters.HTTPAdapter):
|
|||
|
||||
|
||||
def request(method, url, data=None, headers=None, auth=None, verify=None,
|
||||
session=None, latin1_fallback=True, tls_fingerprint=None):
|
||||
session=None, latin1_fallback=True, verify_fingerprint=None):
|
||||
'''
|
||||
Wrapper method for requests, to ease logging and mocking. Parameters should
|
||||
be the same as for ``requests.request``, except:
|
||||
|
||||
:param session: A requests session object to use.
|
||||
:param verify_fingerprint: Optional. SHA1 or MD5 fingerprint of the
|
||||
expected server certificate.
|
||||
:param latin1_fallback: RFC-2616 specifies the default Content-Type of
|
||||
text/* to be latin1, which is not always correct, but exactly what
|
||||
requests is doing. Setting this parameter to False will use charset
|
||||
|
|
@ -211,11 +213,11 @@ def request(method, url, data=None, headers=None, auth=None, verify=None,
|
|||
if session is None:
|
||||
session = requests.Session()
|
||||
|
||||
if tls_fingerprint is not None:
|
||||
if verify_fingerprint is not None:
|
||||
https_prefix = 'https://'
|
||||
|
||||
if not isinstance(session.adapters[https_prefix], _FingerprintAdapter):
|
||||
fingerprint_adapter = _FingerprintAdapter(tls_fingerprint)
|
||||
fingerprint_adapter = _FingerprintAdapter(verify_fingerprint)
|
||||
session.mount(https_prefix, fingerprint_adapter)
|
||||
|
||||
func = session.request
|
||||
|
|
|
|||
Loading…
Reference in a new issue