Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0539aed2 authored by JONGLEZ Baptiste's avatar JONGLEZ Baptiste
Browse files

Load system CA bundle by default to solve SSL errors inside Grid'5000

parent 9e7bd874
No related branches found
No related tags found
1 merge request!7Improve SSL user experience on Grid'5000
...@@ -19,6 +19,7 @@ from .__version__ import __version__ ...@@ -19,6 +19,7 @@ from .__version__ import __version__
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
DEFAULT_BASE_URL = "https://api.grid5000.fr/stable" DEFAULT_BASE_URL = "https://api.grid5000.fr/stable"
DEFAULT_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt"
USER_AGENT = "python-grid5000 %s" % __version__ USER_AGENT = "python-grid5000 %s" % __version__
...@@ -61,7 +62,7 @@ class Grid5000(object): ...@@ -61,7 +62,7 @@ class Grid5000(object):
uri=DEFAULT_BASE_URL, uri=DEFAULT_BASE_URL,
username=None, username=None,
password=None, password=None,
verify_ssl=True, verify_ssl=None,
timeout=None, timeout=None,
session=None, session=None,
sslcert=None, sslcert=None,
...@@ -74,6 +75,18 @@ class Grid5000(object): ...@@ -74,6 +75,18 @@ class Grid5000(object):
self.username = username self.username = username
self.password = password self.password = password
self.verify_ssl = verify_ssl self.verify_ssl = verify_ssl
if self.verify_ssl is None:
# By default, requests ignores trusted CA from the system
# (it uses certifi instead).
# On Grid'5000 frontend and nodes, it is necessary to use the
# system CA bundle, because it includes the root Grid'5000 CA
# allowing to validate the internal API certificate.
ca_bundle = Path(DEFAULT_CA_BUNDLE)
if ca_bundle.exists():
self.verify_ssl = ca_bundle
else:
# As a last resort, use certifi
self.verify_ssl = True
self.client_ssl = False self.client_ssl = False
self.client_cert = None self.client_cert = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment