@@ -2,6 +2,7 @@ package Net::SAML2::IdP;
22use Moose;
33use MooseX::Types::Moose qw/ Str Object HashRef ArrayRef / ;
44use MooseX::Types::URI qw/ Uri / ;
5+ use Net::SAML2::XML::Util qw/ no_comments / ;
56
67=head1 NAME
78
@@ -59,7 +60,7 @@ sub new_from_url {
5960
6061 my $res = $ua -> request($req );
6162 die " no metadata" unless $res -> is_success;
62- my $xml = $res -> content;
63+ my $xml = no_comments( $res -> content) ;
6364
6465 return $class -> new_from_xml(xml => $xml , cacert => $args {cacert });
6566}
@@ -74,7 +75,7 @@ document.
7475sub new_from_xml {
7576 my ($class , %args ) = @_ ;
7677
77- my $xpath = XML::XPath-> new(xml => $args {xml });
78+ my $xpath = XML::XPath-> new(xml => no_comments( $args {xml }) );
7879 $xpath -> set_namespace(' md' , ' urn:oasis:names:tc:SAML:2.0:metadata' );
7980 $xpath -> set_namespace(' ds' , ' http://www.w3.org/2000/09/xmldsig#' );
8081
@@ -126,12 +127,12 @@ sub new_from_xml {
126127 $data -> {NameIDFormat }-> {unspecified } = ' urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified' ;
127128 $data -> {DefaultFormat } = ' unspecified' unless exists $data -> {DefaultFormat };
128129 }
129-
130+
130131 for my $key (
131132 $xpath -> findnodes(' //md:EntityDescriptor/md:IDPSSODescriptor/md:KeyDescriptor' ))
132133 {
133134 my $use = $key -> getAttribute(' use' ) || ' signing' ;
134-
135+
135136 # We can't select by ds:KeyInfo/ds:X509Data/ds:X509Certificate
136137 # because of https://rt.cpan.org/Public/Bug/Display.html?id=8784
137138 my ($text )
@@ -172,7 +173,7 @@ sub new_from_xml {
172173
173174sub BUILD {
174175 my ($self ) = @_ ;
175-
176+
176177 if ($self -> cacert) {
177178 my $ca = Crypt::OpenSSL::VerifyX509-> new($self -> cacert);
178179
0 commit comments