diff --git a/letsencrypt/client/acme.py b/letsencrypt/client/acme.py index 347b28494..f51fae296 100644 --- a/letsencrypt/client/acme.py +++ b/letsencrypt/client/acme.py @@ -37,8 +37,9 @@ def acme_object_validate(json_string, schemata=None): :type schemata: dict :returns: None if validation was successful. - :raises: jsonschema.ValidationError if validation was unsuccessful - ValueError if the object cannot even be parsed as valid JSON + + :raises jsonschema.ValidationError: if validation was unsuccessful + :raises ValueError: if the object cannot even be parsed as valid JSON """ schemata = SCHEMATA if schemata is None else schemata diff --git a/letsencrypt/client/client.py b/letsencrypt/client/client.py index 6b625fc37..a23e7ee1b 100644 --- a/letsencrypt/client/client.py +++ b/letsencrypt/client/client.py @@ -69,10 +69,11 @@ class Client(object): # TODO: Figure out all exceptions from this function try: self._validate_csr_key_cli() - except Exception as exc: + + except errors.LetsEncryptClientError as e: # TODO: Something nice here... - logger.fatal(("%s - until the programmers get their act together, " - "we are just going to exit" % str(exc))) + logger.fatal("%s - until the programmers get their act together, " + "we are just going to exit" % e) sys.exit(1) self.server_url = "https://%s/acme/" % self.server @@ -129,9 +130,9 @@ class Client(object): _, csr_der = self.get_key_csr_pem() # TODO: Handle this exception/problem - if not crypto_util.csr_matches_names(self.csr, self.names): - raise errors.LetsEncryptClientError(("CSR subject does not contain " - "one of the specified names")) + if not crypto_util.csr_matches_names(self.csr_file, self.names): + raise errrors.LetsEncryptClientError( + "CSR subject does not contain one of the specified names") # Perform Challenges responses, challenge_objs = self.verify_identity(challenge_msg) @@ -313,7 +314,7 @@ class Client(object): :returns: ACME response message from server. :rtype: dict - :raises errors.LetsEncryptClientError: + :raises LetsEncryptClientError: if server sent ACME "error" message """ for _ in xrange(rounds): @@ -698,6 +699,8 @@ class Client(object): Verifies that the client key and csr arguments are valid and correspond to one another. + :raises LetsEncryptClientError: if validation fails + """ # TODO: Handle all of these problems appropriately # The client can eventually do things like prompt the user @@ -705,20 +708,20 @@ class Client(object): # If CSR is provided, it must be readable and valid. if self.csr and not crypto_util.valid_csr(self.csr): - raise errors.LetsEncryptClientError("The provided CSR is not a " - "valid CSR") + raise errors.LetsEncryptClientError( + "The provided CSR is not a valid CSR") # If key is provided, it must be readable and valid. if self.privkey and not crypto_util.valid_privkey(self.privkey): - raise errors.LetsEncryptClientError("The provided key is not a " - "valid key") + raise errors.LetsEncryptClientError( + "The provided key is not a valid key") # If CSR and key are provided, the key must be the same key used # in the CSR. if self.csr and self.privkey: if not crypto_util.csr_matches_pubkey(self.csr, self.privkey): - raise errors.LetsEncryptClientError("The key and CSR do not " - "match") + raise errors.LetsEncryptClientError( + "The key and CSR do not match") def get_all_names(self): """Return all valid names in the configuration.""" diff --git a/letsencrypt/client/le_util.py b/letsencrypt/client/le_util.py index 70b9f5a86..4d76a5d21 100644 --- a/letsencrypt/client/le_util.py +++ b/letsencrypt/client/le_util.py @@ -4,6 +4,8 @@ import errno import os import stat +from letsencrypt.client import errors + def make_or_verify_dir(directory, mode=0o755, uid=0): """Make sure directory exists with proper permissions. @@ -17,7 +19,8 @@ def make_or_verify_dir(directory, mode=0o755, uid=0): :param uid: Directory owner. :type uid: int - :raises: Exception -- TODO + :raises LetsEncryptClientError: if a directory already exists, + but has wrong permissions or owner """ try: @@ -25,8 +28,9 @@ def make_or_verify_dir(directory, mode=0o755, uid=0): except OSError as exception: if exception.errno == errno.EEXIST: if not check_permissions(directory, mode, uid): - raise Exception('%s exists and does not contain the proper ' - 'permissions or owner' % directory) + raise errors.LetsEncryptClientError( + '%s exists and does not contain the proper ' + 'permissions or owner' % directory) else: raise @@ -90,7 +94,7 @@ def jose_b64encode(data): :param data: Data to be encoded. :type data: str or bytearray - :raises: TypeError + :raises TypeError: if input is of incorrect type :returns: JOSE Base64 string. :rtype: str @@ -108,7 +112,8 @@ def jose_b64decode(data): only ASCII characters are allowed. :type data: str or unicode - :raises: ValueError, TypeError + :raises TypeError: if input is of incorrect type + :raises ValueError: if unput is unicode with non-ASCII characters :returns: Decoded data.