summaryrefslogtreecommitdiff
path: root/src/leap/config/providerconfig.py
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-08-01 15:35:01 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-08-01 15:41:46 -0300
commite1a192b4aebb8a2448f1cc7258a03dadc5970678 (patch)
treedca779a078bc296c9a9ec49f3ce900d4f7d21f83 /src/leap/config/providerconfig.py
parent233622752ee3098a3bee9ed1539573912cde18e3 (diff)
Replace assert with check and add exception.
Diffstat (limited to 'src/leap/config/providerconfig.py')
-rw-r--r--src/leap/config/providerconfig.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/leap/config/providerconfig.py b/src/leap/config/providerconfig.py
index 744199f8..eb097034 100644
--- a/src/leap/config/providerconfig.py
+++ b/src/leap/config/providerconfig.py
@@ -21,13 +21,20 @@ Provider configuration
import logging
import os
-from leap.common.check import leap_assert
+from leap.common.check import leap_check
from leap.common.config.baseconfig import BaseConfig, LocalizedKey
from leap.config.provider_spec import leap_provider_spec
logger = logging.getLogger(__name__)
+class MissingCACert(Exception):
+ """
+ Raised when a CA certificate is needed but not found.
+ """
+ pass
+
+
class ProviderConfig(BaseConfig):
"""
Provider configuration abstraction class
@@ -118,6 +125,8 @@ class ProviderConfig(BaseConfig):
def get_ca_cert_path(self, about_to_download=False):
"""
Returns the path to the certificate for the current provider.
+ It may raise MissingCACert if
+ the certificate does not exists and not about_to_download
:param about_to_download: defines wether we want the path to
download the cert or not. This helps avoid
@@ -135,8 +144,9 @@ class ProviderConfig(BaseConfig):
"cacert.pem")
if not about_to_download:
- leap_assert(os.path.exists(cert_path),
- "You need to download the certificate first")
+ cert_exists = os.path.exists(cert_path)
+ error_msg = "You need to download the certificate first"
+ leap_check(cert_exists, error_msg, MissingCACert)
logger.debug("Going to verify SSL against %s" % (cert_path,))
return cert_path