Skip to content

Commit 535acba

Browse files
author
Hans Hörberg
committed
Added code to retrieve certificate.
1 parent bc9a7bc commit 535acba

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,5 @@ example/sp/sp_nocert.xml
147147
example/sp/sp_nocert2.xml
148148

149149
example/sp/test.py
150+
151+
example/sp/sp_conf.py

src/saml2/authn_context/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def _pick_by_class_ref(self, cls_ref, comparision_type="exact"):
136136
res = []
137137

138138
for ref in _refs[1:]:
139-
item = self.db[ref]
139+
item = self.db["info"][ref]
140140
res.append((item["method"], ref))
141141
if func(_level, item["level"]):
142142
_level = item["level"]

src/saml2/server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ def __init__(self, config_file="", config=None, cache=None, stype="idp",
8383
self.iv = os.urandom(16)
8484
self.lock = threading.Lock()
8585

86+
def getvalid_certificate_str(self):
87+
if self.sec.cert_handler is not None:
88+
return self.sec.cert_handler._last_validated_cert
89+
return None
90+
8691
def support_AssertionIDRequest(self):
8792
return True
8893

src/saml2/sigver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ def __init__(self, security_context, cert_file=None, cert_type="pem", key_file=N
964964
"""
965965
self._verify_cert = False
966966
self._generate_cert = False
967+
self._last_cert_verified = None #This cert do not have to be valid, it is just the last cert to be validated.
967968
if cert_type == "pem" and key_type == "pem":
968969
self._verify_cert = verify_cert is True
969970
self._security_context = security_context
@@ -993,6 +994,7 @@ def __init__(self, security_context, cert_file=None, cert_type="pem", key_file=N
993994
def verify_cert(self, cert_file):
994995
if self._verify_cert:
995996
cert_str = self._osw.read_str_from_file(cert_file, "pem")
997+
self._last_validated_cert = cert_str
996998
if self._cert_handler_extra_class is not None and self._cert_handler_extra_class.use_validate_cert_func():
997999
self._cert_handler_extra_class.validate_cert(cert_str, self._cert_str, self._key_str)
9981000
else:

0 commit comments

Comments
 (0)