Fixing error IO::Socket::SSL 1.56 must be installed for https support
In the Perl programming language there are several libraries you can use
to download data from the Internet Protocol HTTP
. The most famous is LWP
and HTTP::Tiny
.
Library HTTP::Tiny
comes with Perl, it is not necessary to install additional,
therefore, it is often convenient to download data with it.
Using Perl to get HTML page with http protocol
Here is an example of code that loads the home page http://example.com
. In this example
uses http and not https:
use strict;
use warnings;
use feature qw(say);
use HTTP::Tiny;
use Data::Dumper;
my $response = HTTP::Tiny->new()->get('http://example.com');
warn Dumper $response;
If you run this code, you can see that everything works. Received the status of 200
. The field success
value
is true (in this text for convenience of display, the data structures have fields content
the value was changed,
instead of the html code of the page written by three dots):
$ perl script.pl
$VAR1 = {
'reason' => 'OK',
'protocol' => 'HTTP/1.1',
'content' => '...',
'headers' => {
'etag' => '"3147526947+gzip+ident"',
'x-cache' => 'HIT',
'connection' => 'close',
'cache-control' => 'max-age=604800',
'content-length' => '1256',
'server' => 'ECS (nyb/1D2A)',
'expires' => 'Mon, 30 Dec 2019 12:38:04 GMT',
'vary' => 'Accept-Encoding',
'content-type' => 'text/html; charset=UTF-8',
'date' => 'Mon, 23 Dec 2019 12:38:04 GMT',
'last-modified' => 'Thu, 17 Oct 2019 07:18:26 GMT'
},
'url' => 'http://example.com',
'success' => 1,
'status' => '200'
};
Error when using https
But if you change a little this code to load data over https, then
the data is not loaded. Here is the code of the program:
use strict;
use warnings;
use feature qw(say);
use HTTP::Tiny;
use Data::Dumper;
my $response = HTTP::Tiny->new()->get('https://example.com');
warn Dumper $response;
Here is the output from this program:
$ perl script.pl
$VAR1 = {
'url' => 'https://example.com',
'reason' => 'Internal Exception',
'status' => 599,
'success' => '',
'headers' => {
'content-type' => 'text/plain',
'content-length' => 57
},
'content' => 'IO::Socket::SSL 1.56 must be installed for https support
'
};
The value of the field status
599
(this special status was invented in the library HTTP::Tiny
, it means that the problem is with the library).
The value success
is false, and the content
there is an explanation of why the error occurred:
IO::Socket::SSL 1.56 must be installed for https support
.
Try to solve
Yeah. To HTTP::Tiny
to work over https need to the library IO::Socket::SSL
.
Try to put her with cpanm
, but get the error:
root@faf6a4b66b08:/app# cpanm IO::Socket::SSL
--> Working on IO::Socket::SSL
Fetching http://www.cpan.org/authors/id/S/SU/SULLR/IO-Socket-SSL-2.066.tar.gz ... OK
==> Found dependencies: Net::SSLeay
--> Working on Net::SSLeay
Fetching http://www.cpan.org/authors/id/C/CH/CHRISN/Net-SSLeay-1.88.tar.gz ... OK
Configuring Net-SSLeay-1.88 ... OK
Building and testing Net-SSLeay-1.88 ... FAIL
! Installing Net::SSLeay failed. See /root/.cpanm/work/1577105006.3284/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'Net::SSLeay' is not installed
! Bailing out the installation for IO-Socket-SSL-2.066.
root@faf6a4b66b08:/app#
As you can see from the log for the library IO::Socket::SSL
need to install Net::SSLeay
, but Net::SSLeay
is not installed.
In the file build.log
you can see the details. Here's a snippet of that file:
cp lib/Net/SSLeay.pod blib/lib/Net/SSLeay.pod
/usr/bin/perl /usr/share/perl/5.18/ExtUtils/xsubpp -typemap /usr/share/perl/5.18/ExtUtils/typemap -typemap typemap SSLeay.xs > SSLeay.xsc && mv SSLeay.xsc SSLeay.c
cc -c -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -DVERSION=\"1.88\" -DXS_VERSION=\"1.88\" -fPIC "-I/usr/lib/perl/5.18/CORE" SSLeay.c
SSLeay.xs:163:25: fatal error: openssl/err.h: No such file or directory
#include openssl/err.h
^
compilation terminated.
make: *** [SSLeay.o] Error 1
A successful solution
To HTTP::Tiny
could work on the Protocol https
need to install the library IO::Socket::SSL
.
To set IO::Socket::SSL
need to install Net::SSLeay
.
But to install the library Net::SSLeay
you need to put an additional library to the system.
On Ubuntu this is done with the command:
$ apt-get update && apt-get install -y libssl-dev
After this you need to install IO::Socket::SSL
:
This command will successfully install the library Net::SSLeay
and IO::Socket::SSL
.
And then HTTP::Tiny will be able to work on the Protocol https
.
Other articles
Some parts of this page were machine translated.
Powered by Yandex.Translate
http://translate.yandex.com/