summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/crypto
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-09-26 10:15:06 -0300
committerTomás Touceda <chiiph@leap.se>2014-09-26 10:15:06 -0300
commit6f7177f3ca359f8c3e74d094b0dcd0f9239fb069 (patch)
treef04b0eb5c4665a129c5c49719b2da65d325b111f /src/leap/bitmask/crypto
parente8c028f3eb6cd0681f039c456dc1ac45c98d598f (diff)
parent0db3d5a4aecc0a3c271b92c6187922c50d46df0a (diff)
Merge branch 'release-0.7.0'0.7.0rc20.7.0rc1
Diffstat (limited to 'src/leap/bitmask/crypto')
-rw-r--r--src/leap/bitmask/crypto/certs.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/leap/bitmask/crypto/certs.py b/src/leap/bitmask/crypto/certs.py
index 244decfd..c3ca4efb 100644
--- a/src/leap/bitmask/crypto/certs.py
+++ b/src/leap/bitmask/crypto/certs.py
@@ -46,19 +46,27 @@ def download_client_cert(provider_config, path, session):
# again.
srp_auth = SRPAuth(provider_config)
session_id = srp_auth.get_session_id()
+ token = srp_auth.get_token()
cookies = None
- if session_id:
+ if session_id is not None:
cookies = {"_session_id": session_id}
cert_uri = "%s/%s/cert" % (
provider_config.get_api_uri(),
provider_config.get_api_version())
logger.debug('getting cert from uri: %s' % cert_uri)
+ headers = {}
+
+ # API v2 will only support token auth, but in v1 we can send both
+ if token is not None:
+ headers["Authorization"] = 'Token token="{0}"'.format(token)
+
res = session.get(cert_uri,
verify=provider_config
.get_ca_cert_path(),
cookies=cookies,
- timeout=REQUEST_TIMEOUT)
+ timeout=REQUEST_TIMEOUT,
+ headers=headers)
res.raise_for_status()
client_cert = res.content