I had a nice script working with a web service via XML::Compile until recently when the web service went to SSL. I'm not really sure how to go about SSL via XML::Compile. Taking a first leap I decided I'll probably need to create an SSL socket:

use strict; use warnings; use IO::Socket::SSL qw(debug3); my $socket = IO::Socket::SSL->new ( PeerAddr => 'some.server.com', PeerPort => 443, Proto => 'tcp', SSL_use_cert => 1, SSL_verify_mode => SSL_VERIFY_NONE, SSL_cert_file => 'server.pem' ) or die "failed connect or ssl handshake: $!,",&IO::Socket::SSL::errs +tr,"\n";

But when I run this, I get a bad return value from Net::SSLeay

DEBUG: .../IO/Socket/SSL.pm:251: set domain to 2 DEBUG: .../IO/Socket/SSL.pm:1784: new ctx 41181280 DEBUG: .../IO/Socket/SSL.pm:446: socket not yet connected DEBUG: .../IO/Socket/SSL.pm:448: socket connected DEBUG: .../IO/Socket/SSL.pm:466: ssl handshake not started DEBUG: .../IO/Socket/SSL.pm:501: using SNI with hostname some.server.c +om DEBUG: .../IO/Socket/SSL.pm:537: Net::SSLeay::connect -> -1 DEBUG: .../IO/Socket/SSL.pm:543: fatal SSL error: SSL connect attempt +failed with unknown error DEBUG: .../IO/Socket/SSL.pm:1821: free ctx 41181280 open=41181280 DEBUG: .../IO/Socket/SSL.pm:1829: OK free ctx 41181280 failed connect or ssl handshake: Bad file descriptor,IO::Socket::INET6 + configuration failed SSL connect attempt failed with unknown error

perl -MNet::SSLeay -e " print Net::SSLeay::SSLeay_version();
reveals "OpenSSL 1.0.1e 11 Feb 2013"

I'm not certain I'm pursuing the right direction, or how I'm actually going to pass the socket into the XML::Compile transport, so I thought I'd stop here for a sanity check.

Other info... I'm having to do this via Windows with Strawberry Perl 5.16.3. I updated a whole slew of libraries (from Net::HTTP* to IO::Socket* to Net:SSL*) I do have the ability to run openssl to get the cert info. I can connect via telnet to the server at port 443. I don't really care about the server verification/certificate as the client is just used for test automation.

Thanks Monks

Update: I found a handy script somewhere (lost the link now) that helped me determine that the SSL was version 3. So adding "SSL_version => 'SSLv3'" to the LWP::UserAgent's ssl_opts got the SSL handshake to complete.

Now I'm stuck on a read timeout. I will be increasing the client timeout on the transport layer underneath the SSL layer.


In reply to Creating SSL socket by jdudleyh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.