diff --git a/src/libsaml.ts b/src/libsaml.ts index 4159cbd2..18e5eba7 100644 --- a/src/libsaml.ts +++ b/src/libsaml.ts @@ -357,6 +357,9 @@ const libSaml = () => { const certificateNode = select(".//*[local-name(.)='X509Certificate']", signatureNode) as any; // certificate in metadata let metadataCert: any = opts.metadata.getX509Certificate(certUse.signing); + if (!metadataCert) { + throw new Error('INVALID_CERTIFICATE_PROVIDED') + } // flattens the nested array of Certificates from each KeyDescriptor if (Array.isArray(metadataCert)) { metadataCert = flattenDeep(metadataCert);