diff --git a/redfish/exception.py b/redfish/exception.py index bb09b86..84b67cf 100644 --- a/redfish/exception.py +++ b/redfish/exception.py @@ -39,16 +39,6 @@ class InvalidRedfishContentException(RedfishException): ' Most of the time you are not pointing to the rest API\n' -class NonTrustedCertificatException(RedfishException): - def __init__(self, message, **kwargs): - super(NonTrustedCertificatException, self).__init__(message, **kwargs) - self.advices = \ - '1- Check if the url is the correct one\n' + \ - '2- Check if your device has a valid trusted certificat\n' + \ - ' You can use openssl to validate it using the command :\n' + \ - ' openssl s_client -showcerts -connect :443\n' - - class AuthenticationFailureException(RedfishException): def __init__(self, message, **kwargs): super(AuthenticationFailureException, self).__init__(message, **kwargs) diff --git a/redfish/types.py b/redfish/types.py index 8777398..478ab53 100644 --- a/redfish/types.py +++ b/redfish/types.py @@ -13,6 +13,7 @@ from urllib.parse import urljoin import requests import simplejson import tortilla +import ssl from . import config from . import mapping from . import exception @@ -31,15 +32,17 @@ class Base(object): try: if connection_parameters.auth_token is None: - self.data = self.api_url.get(verify=connection_parameters.verify_cert) + self.data = self.api_url.get( + verify=connection_parameters.verify_cert) else: - self.data = self.api_url.get(verify=connection_parameters.verify_cert, - headers={'x-auth-token': connection_parameters.auth_token} - ) - except requests.ConnectionError as e: + self.data = self.api_url.get( + verify=connection_parameters.verify_cert, + headers={ + 'x-auth-token': connection_parameters.auth_token}) + except (requests.ConnectionError, ssl.SSLError) as e: # Log and transmit the exception. config.logger.info('Raise a RedfishException to upper level') - msg = 'Connection error : {}\n'.format(e.message) + msg = 'Connection error : {}\n'.format(e) raise exception.ConnectionFailureException(msg) except simplejson.scanner.JSONDecodeError as e: # Log and transmit the exception. @@ -48,14 +51,6 @@ class Base(object): 'Ivalid content : Content does not appear to be a valid ' + \ 'Redfish json\n' raise exception.InvalidRedfishContentException(msg) - except TypeError as e: - # This happen connecting to a manager using non trusted - # SSL certificats. - # The exception is not what could be expected in such case but this - # is the one provided by Tortilla. - config.logger.info('Raise a RedfishException to upper level') - msg = 'Connection error\n' - raise exception.NonTrustedCertificatException(msg) config.logger.debug(self.data) def get_link_url(self, link_type):