Subject: | bug when SOAP::Lite is trying to parse WSDL definition by https with custom settings |
There is a bug when SOAP::Lite is trying to parse WSDL definition by https with custom settings (e.
g. with certificate authentication added by $soap->schema->useragent->ssl_opts(...) or by custom user agent) and this top-level WSDL has link to other WSDL-definition, like this:
wsdl:import location="https://site.tld/services/AnyService?wsdl=AnyService.wsdl" namespace="..."
Imported location is being accessed by https, but without custom ssl_opts or using default user agent - custom user agent is not used in sub "parse" when new SOAP::Schema::WSDL object is created.
Example of such code:
my $soap = SOAP::Lite->new;
$soap->schema->useragent->ssl_opts(
SSL_use_cert => 1,
SSL_cert_file => 'mycert.pem',
SSL_key_file => 'mykey.pem',
);
$soap->service(WSDL_URI);
In this case, if WSDL_URI has wsdl:import tag with other location, this location is being accessed without mycert.pem & mykey.pem (which leads to "Forbidden" in most cases).
And in this case error diagnostic is somewhat confused, especially if you are using self-signed certs, because it warns, that LWP could not verify https-site and asks about ca-certs (and if you turn on debug3 on IO::Socket::SSL you can see, that it complains only on second https-connect).
The reason of error is, that custom schema->useragent from SOAP::Lite object was not reused when SOAP::Schema::WSDL object is created to parse imported location.
The following patch solves this problem:
Subject: | SOAP-Lite-useragent.patch |
--- SOAP/Lite.pm- 2014-02-13 11:01:12.000000000 +0100
+++ SOAP/Lite.pm 2014-02-13 11:37:49.000000000 +0100
@@ -3260,7 +3260,7 @@
my $self = shift;
my $s = $self->deserializer->deserialize($self->access)->root;
# here should be something that defines what schema description we want to use
- $self->services({SOAP::Schema::WSDL->base($self->schema_url)->parse($s, @_)});
+ $self->services({SOAP::Schema::WSDL->base($self->schema_url)->useragent($self->useragent)->parse($s, @_)});
}
sub refresh_cache {