Subject: | Segmentation fault on malformed certificate file |
Date: | Tue, 14 Nov 2017 16:07:10 +0300 |
To: | bug-IO-Socket-SSL [...] rt.cpan.org |
From: | Dmitry Belyavsky <beldmit [...] gmail.com> |
Hello,
I get a segmentation fault using malformed clients certificate and private
key.
Minimal example:
=========
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use LWP::UserAgent;
use IO::Socket::SSL qw(debug3);
my $ua = LWP::UserAgent->new(
ssl_opts => {
SSL_cert_file => '/srv/vr/experiment/cert.pem',
SSL_key_file => '/srv/vr/experiment/key.pem',
}
);
my $response = $ua->get("https://my.cool.url");
=========
The debug output is
=========
SSL error: 38061: 1 - error:0D07803A:asn1 encoding
routines:ASN1_ITEM_EX_D2I:nested asn1 error
DEBUG: .../IO/Socket/SSL.pm:1774: Failed to use certificate file
error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
DEBUG: .../IO/Socket/SSL.pm:529: socket not yet connected
DEBUG: .../IO/Socket/SSL.pm:531: socket connected
DEBUG: .../IO/Socket/SSL.pm:553: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:1769: SSL structure creation failed
DEBUG: .../IO/Socket/SSL.pm:1774: SSL structure creation failed
error:140BA0C3:SSL routines:SSL_new:null ssl ctx
DEBUG: .../IO/Socket/SSL.pm:640: set socket to non-blocking to enforce
timeout=180
Segmentation fault (core dumped)
==========
When I try to reproduce it with the same certificate and key on the other
machine, I get a normal shutdown with different debug output:
==========
DEBUG: .../IO/Socket/SSL.pm:1769: Failed to use certificate file
SSL error: 45289: 1 - error:0D07803A:asn1 encoding
routines:ASN1_ITEM_EX_D2I:nested asn1 error
DEBUG: .../IO/Socket/SSL.pm:1774: Failed to use certificate file
error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
DEBUG: .../IO/Socket/SSL.pm:529: socket not yet connected
DEBUG: .../IO/Socket/SSL.pm:531: socket connected
DEBUG: .../IO/Socket/SSL.pm:553: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:1769: SSL structure creation failed
DEBUG: .../IO/Socket/SSL.pm:1774: SSL structure creation failed
error:140BA0C3:SSL routines:SSL_new:null ssl ctx
DEBUG: .../IO/Socket/SSL.pm:1758: IO::Socket::IP configuration failed
==========
Thank you!
--
SY, Dmitry Belyavsky