Skip to content

Commit d46073c

Browse files
committed
Specify Canonical exclusive mode for XML::Sig
1 parent 597d346 commit d46073c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

lib/Net/SAML2/Binding/POST.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ sub handle_response {
6161
my $xml = no_comments(decode_base64($response));
6262
my $xml_opts = { x509 => 1 };
6363
$xml_opts->{ cert_text } = $self->cert_text if ($self->cert_text);
64+
$xml_opts->{ exclusive } = 1;
6465
my $x = Net::SAML2::XML::Sig->new($xml_opts);
6566
my $ret = $x->verify($xml);
6667
die "signature check failed" unless $ret;

lib/Net/SAML2/Binding/SOAP.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ sub handle_response {
112112
my ($self, $response) = @_;
113113

114114
# verify the response
115-
my $x = Net::SAML2::XML::Sig->new({ x509 => 1, cert_text => $self->idp_cert });
115+
my $x = Net::SAML2::XML::Sig->new({ x509 => 1, cert_text => $self->idp_cert, exclusive => 1, });
116116
my $ret = $x->verify($response);
117117
die "bad SOAP response" unless $ret;
118118

@@ -151,7 +151,7 @@ sub handle_request {
151151
my $saml = $parser->findnodes_as_string('/soap-env:Envelope/soap-env:Body/*');
152152

153153
if (defined $saml) {
154-
my $x = Net::SAML2::XML::Sig->new({ x509 => 1, cert_text => $self->idp_cert });
154+
my $x = Net::SAML2::XML::Sig->new({ x509 => 1, cert_text => $self->idp_cert, exclusive => 1, });
155155
my $ret = $x->verify($saml);
156156
die "bad signature" unless $ret;
157157

@@ -181,6 +181,7 @@ sub create_soap_envelope {
181181
x509 => 1,
182182
key => $self->key,
183183
cert => $self->cert,
184+
exclusive => 1,
184185
});
185186
my $signed_message = $sig->sign($message);
186187

lib/Net/SAML2/XML/Sig.pm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ sub new {
5050
$self->{ 'canonicalizer' } =
5151
exists $params->{ canonicalizer } ? $params->{ canonicalizer } : 'XML::CanonicalizeXML';
5252
$self->{ 'x509' } = exists $params->{ x509 } ? 1 : 0;
53+
$self->{ 'exclusive' } = exists $params->{ exclusive } ? $params->{ exclusive } : 1;
5354
if ( exists $params->{ 'key' } ) {
5455
$self->_load_key( $params->{ 'key' } );
5556
}
@@ -658,7 +659,7 @@ sub _canonicalize_xml {
658659
# adjust prefixlist from attribute for XML::CanonicalizeXML's format
659660
$prefixlist =~ s/ /,/g;
660661

661-
return XML::CanonicalizeXML::canonicalize( $xml, $xpath, $prefixlist, 1, $comments );
662+
return XML::CanonicalizeXML::canonicalize( $xml, $xpath, $prefixlist, $self->{ exclusive }, $comments );
662663
}
663664
else {
664665
confess "Unknown XML canonicalizer module.";
@@ -898,6 +899,12 @@ XML::Canonical was removed as an option due to its age
898899
899900
=back
900901
902+
=item B<exclusive>
903+
904+
The XML::CanonicalizerXML exclusive method. exclusive is an int to specify exclusive canonicalization (1 = exclusive, 0 = non-exclusive, 2 = exclusive v1.1)
905+
906+
default = 1
907+
901908
=item B<x509>
902909
903910
Takes a true (1) or false (0) value and indicates how you want the

0 commit comments

Comments
 (0)