diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-18 22:55:51 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2017-04-19 20:14:30 +0200 |
commit | 6227a8ed9c1184eb01eca4e23cc419473e5c5b51 (patch) | |
tree | e292a90c796d2b20cf194235c9cac78142ab5223 /src/leap | |
parent | 6756e922e9fe5e8f678d3ccaefadb27c23f400ae (diff) |
[bug] return clearer errors when no cert found
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/bitmask/vpn/_control.py | 5 | ||||
-rw-r--r-- | src/leap/bitmask/vpn/service.py | 16 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/leap/bitmask/vpn/_control.py b/src/leap/bitmask/vpn/_control.py index a490934..6d4db96 100644 --- a/src/leap/bitmask/vpn/_control.py +++ b/src/leap/bitmask/vpn/_control.py @@ -61,11 +61,6 @@ class VPNControl(object): logger.info("Another vpn process is running. Will try to stop it.") vpnproc.stop_if_already_running() - # FIXME it would be good to document where the - # errors here are catched, since we currently handle them - # at the frontend layer. This *should* move to be handled entirely - # in the backend. - try: cmd = vpnproc.getCommand() except Exception as e: diff --git a/src/leap/bitmask/vpn/service.py b/src/leap/bitmask/vpn/service.py index 2766b8c..026f459 100644 --- a/src/leap/bitmask/vpn/service.py +++ b/src/leap/bitmask/vpn/service.py @@ -35,6 +35,12 @@ from leap.common.files import check_and_fix_urw_only from leap.common.certs import get_cert_time_boundaries +class ImproperlyConfigured(Exception): + """This error is a transient exception until autoconf automates all the + needed steps for VPN bootstrap.""" + expected = True + + class VPNService(HookableService): name = 'vpn' @@ -121,6 +127,8 @@ class VPNService(HookableService): try: _, provider = username.split('@') except ValueError: + if not username: + raise ValueError('Need an username. are you logged in?') raise ValueError(username + ' is not a valid username, it should' ' contain an @') @@ -163,6 +171,14 @@ class VPNService(HookableService): cert_path = key_path = os.path.join(prefix, "client", "openvpn.pem") ca_path = os.path.join(prefix, "ca", "cacert.pem") + if not os.path.isfile(cert_path): + raise ImproperlyConfigured( + 'Cannot find client certificate. Please get one') + if not os.path.isfile(ca_path): + raise ImproperlyConfigured( + 'Cannot find provider certificate. ' + 'Please configure provider.') + self._vpn = VPNManager(provider, remotes, cert_path, key_path, ca_path, extra_flags) |