Skip to content

Commit

Permalink
Ensure xml signed via id_attr can be verified
Browse files Browse the repository at this point in the history
  • Loading branch information
timlegge committed Jul 19, 2022
1 parent 028c851 commit b26f8ba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions t/008_sign_saml.t
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,22 @@ ok($xmlsec_ret, "xmlsec1: RSA Verifed Successfully");

# SAML metadata
my $md = slurp_file(catfile(qw(t unsigned saml_metadata.xml)));
my $signed = XML::Sig->new(

$sig = XML::Sig->new(
{
x509 => 1,
key => 't/rsa.private.key',
cert => 't/rsa.cert.pem',
# The syntax is similar to xmlsec: --id-attr:ID urn:...:EntityDescriptor
ns => { md => 'urn:oasis:names:tc:SAML:2.0:metadata' },
id_attr => '/md:EntityDescriptor[@ID]',
}
)->sign($md);
});

my $signed = $sig->sign($md);

$ret = $sig->verify($signed);

ok($ret, "Verified SAML metadata signature");

my $xp = XML::LibXML::XPathContext->new(
XML::LibXML->load_xml(string => $signed)
Expand Down

0 comments on commit b26f8ba

Please sign in to comment.