From 6227a8ed9c1184eb01eca4e23cc419473e5c5b51 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 18 Apr 2017 22:55:51 +0200 Subject: [bug] return clearer errors when no cert found --- src/leap/bitmask/vpn/_control.py | 5 ----- src/leap/bitmask/vpn/service.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/leap/bitmask/vpn') 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) -- cgit v1.2.3