summaryrefslogtreecommitdiff
path: root/src/leap/eip
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/eip')
-rw-r--r--src/leap/eip/checks.py10
-rw-r--r--src/leap/eip/config.py34
-rw-r--r--src/leap/eip/specs.py2
-rw-r--r--src/leap/eip/tests/data.py2
-rw-r--r--src/leap/eip/tests/test_checks.py10
5 files changed, 40 insertions, 18 deletions
diff --git a/src/leap/eip/checks.py b/src/leap/eip/checks.py
index ef09a582..9b7b1cee 100644
--- a/src/leap/eip/checks.py
+++ b/src/leap/eip/checks.py
@@ -197,7 +197,8 @@ class ProviderCertChecker(object):
logger.warning('False! CERT VERIFICATION FAILED! '
'(this should be CRITICAL)')
logger.warning('SSLError: %s', exc.message)
- raise eipexceptions.EIPBadCertError
+ # XXX RAISE! See #638
+ #raise eipexceptions.EIPBadCertError
# XXX get requests.exceptions.ConnectionError Errno 110
# Connection timed out, and raise ours.
else:
@@ -227,7 +228,11 @@ class ProviderCertChecker(object):
if verify is True and self.cacert is not None:
verify = self.cacert
try:
- req = self.fetcher.get(uri, verify=verify)
+ # XXX FIXME!!!!
+ # verify=verify
+ # Workaround for #638. return to verification
+ # when That's done!!!
+ req = self.fetcher.get(uri, verify=False)
req.raise_for_status()
except requests.exceptions.SSLError:
logger.warning('SSLError while fetching cert. '
@@ -452,6 +457,7 @@ class EIPConfigChecker(object):
# XXX TODO:
# We should WRITE eip config if missing or
# incomplete at this point
+ #self.eipconfig.save()
#
# private helpers
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index 24e837d0..082cc24d 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -55,21 +55,35 @@ def get_socket_path():
def get_eip_gateway():
"""
- return the first host in the list of hosts
- under gateways list
+ return the first host in eip service config
+ that matches the name defined in the eip.json config
+ file.
"""
+ placeholder = "testprovider.example.org"
eipconfig = EIPConfig()
eipconfig.load()
conf = eipconfig.get_config()
- gateways = conf.get('gateways', None)
+ primary_gateway = conf.get('primary_gateway', None)
+ if not primary_gateway:
+ return placeholder
+
+ eipserviceconfig = EIPServiceConfig()
+ eipserviceconfig.load()
+ eipsconf = eipserviceconfig.get_config()
+ gateways = eipsconf.get('gateways', None)
+ if not gateways:
+ logger.error('missing gateways in eip service config')
+ return placeholder
if len(gateways) > 0:
- # we just pick first
- gw = gateways[0]
- hosts = gw['hosts']
- if len(hosts) > 0:
- return hosts[0]
- else:
- return "testprovider.example.org"
+ for gw in gateways:
+ if gw['name'] == primary_gateway:
+ hosts = gw['hosts']
+ if len(hosts) > 0:
+ return hosts[0]
+ else:
+ logger.error('no hosts')
+ logger.error('could not find primary gateway in provider'
+ 'gateway list')
def build_ovpn_options(daemon=False, socket_path=None, **kwargs):
diff --git a/src/leap/eip/specs.py b/src/leap/eip/specs.py
index 05aef590..2391e919 100644
--- a/src/leap/eip/specs.py
+++ b/src/leap/eip/specs.py
@@ -59,7 +59,7 @@ eipconfig_spec = {
},
'primary_gateway': {
'type': unicode,
- 'default': u"usa_west",
+ 'default': u"turkey",
'required': True
},
'secondary_gateway': {
diff --git a/src/leap/eip/tests/data.py b/src/leap/eip/tests/data.py
index 4da0e18f..9bf86540 100644
--- a/src/leap/eip/tests/data.py
+++ b/src/leap/eip/tests/data.py
@@ -22,7 +22,7 @@ EIP_SAMPLE_JSON = {
"keys/client/openvpn.pem" % PROVIDER),
"connect_on_login": True,
"block_cleartext_traffic": True,
- "primary_gateway": "usa_west",
+ "primary_gateway": "turkey",
"secondary_gateway": "france",
#"management_password": "oph7Que1othahwiech6J"
}
diff --git a/src/leap/eip/tests/test_checks.py b/src/leap/eip/tests/test_checks.py
index 42aa9cce..19b54c04 100644
--- a/src/leap/eip/tests/test_checks.py
+++ b/src/leap/eip/tests/test_checks.py
@@ -331,10 +331,12 @@ class ProviderCertCheckerHTTPSTests(BaseHTTPSServerTestCase, BaseLeapTest):
fetcher.get(uri, verify=True)
self.assertTrue(
"SSL23_GET_SERVER_HELLO:unknown protocol" in exc.message)
- with self.assertRaises(eipexceptions.EIPBadCertError) as exc:
- checker.is_https_working(uri=uri, verify=True)
- self.assertTrue(
- "cert verification failed" in exc.message)
+
+ # XXX FIXME! Uncomment after #638 is done
+ #with self.assertRaises(eipexceptions.EIPBadCertError) as exc:
+ #checker.is_https_working(uri=uri, verify=True)
+ #self.assertTrue(
+ #"cert verification failed" in exc.message)
# get cacert from testing.https_server
cacert = where_cert('cacert.pem')