I want to use LWP::UserAgent to send some requests over HTTPS. There is this sentence in the ssl_opts section in the documentation
Other options can be set and are processed directly by the SSL Socket implementation in use. See IO::Socket::SSL or Net::SSL for details.
I have installed both modules on my machine and I think I have some problems because of it.
How can I find out which one is in use and how to change it to use the other module?
If you look at
LWP::UserAgent
documentation it says you need to installLWP::Protocol::https
module to have support forhttps://
URIs.If you look at this module in turn you see that it does use the
Net::HTTP
distribution, into which you find aHTTPS.pm
module (see it online at https://metacpan.org/source/OALDERS/Net-HTTP-6.18/lib/Net/HTTPS.pm) where at the beginning you can clearly see that, except if overriden, it first start to try usingIO::Socket::SSL
and next only searches forNet::SSL
.See:
If they are not loaded yet, it tries to load them, in the same order:
So, in short,
IO::Socket::SSL
has full precedence.Inside your program, after having used
LWP::UserAgent
you can use the$Net::HTTPS::SSL_SOCKET_CLASS
variable to know which class has been used for HTTPS operations.If you read the beginning of the code you will see:
which means that before everything above if the environment has a variable
PERL_NET_HTTPS_SSL_SOCKET_CLASS
defined, then its value is used as a class to do operations, if its name is eitherIO::Socket::SSL
orNet::SSL
.So, either set it in your environment before starting your program that uses
LWP::UserAgent
or do something like that in your program:This needs to happen before you do
use LWP::UserAgent;