Skip to content

Commit 041aa27

Browse files
author
Roland Hedberg
committed
Allow signature verification even on local files.
1 parent 2ee7325 commit 041aa27

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/saml2/mdstore.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ def repack_cert(cert):
107107

108108
class MetaData(object):
109109
def __init__(self, onts, attrc, metadata="", node_name=None,
110-
check_validity=True, **kwargs):
110+
check_validity=True, security=None, **kwargs):
111111
self.onts = onts
112112
self.attrc = attrc
113113
self.entity = {}
114114
self.metadata = metadata
115-
self.security = None
115+
self.security = security
116116
self.node_name = node_name
117117
self.entities_descr = None
118118
self.entity_descr = None
@@ -412,11 +412,13 @@ class MetaDataLoader(MetaDataFile):
412412
Handles Metadata file loaded by a passed in function.
413413
The format of the file is the SAML Metadata format.
414414
"""
415-
def __init__(self, onts, attrc, loader_callable, cert=None, **kwargs):
415+
def __init__(self, onts, attrc, loader_callable, cert=None,
416+
security=None, **kwargs):
416417
MetaData.__init__(self, onts, attrc, **kwargs)
417418
self.metadata_provider_callable = self.get_metadata_loader(
418419
loader_callable)
419420
self.cert = cert
421+
self.security = security
420422

421423
@staticmethod
422424
def get_metadata_loader(func):

src/saml2/sigver.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,11 @@ def __init__(self, security_context, cert_file=None, cert_type="pem",
11191119
self._verify_cert = verify_cert is True
11201120
self._security_context = security_context
11211121
self._osw = OpenSSLWrapper()
1122-
if key_file is not None and os.path.isfile(key_file):
1122+
if key_file and os.path.isfile(key_file):
11231123
self._key_str = self._osw.read_str_from_file(key_file, key_type)
11241124
else:
11251125
self._key_str = ""
1126-
if cert_file is not None:
1126+
if cert_file and os.path.isfile(key_file):
11271127
self._cert_str = self._osw.read_str_from_file(cert_file,
11281128
cert_type)
11291129
else:

tools/verify_metadata.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@
6161
kwargs = {}
6262

6363
if args.type == "local":
64-
metad = MetaDataFile(ONTS.values(), args.item, args.item, **kwargs)
64+
if args.cert and args.xmlsec:
65+
crypto = _get_xmlsec_cryptobackend(args.xmlsec)
66+
sc = SecurityContext(crypto)
67+
metad = MetaDataFile(ONTS.values(), args.item, args.item,
68+
cert=args.cert, security=sc, **kwargs)
69+
else:
70+
metad = MetaDataFile(ONTS.values(), args.item, args.item, **kwargs)
6571
elif args.type == "external":
6672
ATTRCONV = ac_factory(args.attrsmap)
6773
httpc = HTTPBase()

0 commit comments

Comments
 (0)