Skip to content

Commit f68b65c

Browse files
author
Roland Hedberg
committed
Allow urls instead of file paths for cert_file, ca_certs and key_file configuration parameters.
1 parent 3678a4e commit f68b65c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/saml2/entity.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from binascii import hexlify
33
import logging
44
from hashlib import sha1
5+
import requests
56
from saml2.metadata import ENDPOINTS
67
from saml2.profile import paos, ecp
78
from saml2.soap import parse_soap_enveloped_saml_artifact_resolve
@@ -118,6 +119,19 @@ def __init__(self, entity_type, config=None, config_file="",
118119
else:
119120
raise SAMLError("Missing configuration")
120121

122+
for item in ["cert_file", "key_file", "ca_certs"]:
123+
_val = getattr(self.config, item, None)
124+
if not _val:
125+
continue
126+
127+
if _val.startswith("http"):
128+
r = requests.request("GET", _val)
129+
if r.status_code == 200:
130+
setattr(self.config, item, r.text)
131+
else:
132+
raise Exception(
133+
"Could not fetch certificate from %s" % _val)
134+
121135
HTTPBase.__init__(self, self.config.verify_ssl_cert,
122136
self.config.ca_certs, self.config.key_file,
123137
self.config.cert_file)

0 commit comments

Comments
 (0)