Hi,

I'm trying to write an SSL proxy using IO::Socket::SSL::Intercept in order to do DNS based inspection of traffic to a specific host, and it's mostly working except I'm seeing strange intermittent failures when trying to connect to the real SSL server on behalf of the client. Here is the relevant code:

# SSL connect to server my $retry = 10; my $server = undef; while ($retry > 0) { $server = IO::Socket::SSL->new( PeerAddr => $host, PeerPort => "https", ); if ($server && $server->connected()) { print "proxy $$ connected to server\n"; last; } else { $retry--; warn "proxy $$ connect to server failed: $!,".IO::Socket:: +SSL::errstr(); warn "proxy $$ ".($retry ? 'will retry' : 'giving up')."\n +"; } }
And here is a typical result. Sometimes it will work the first time, sometimes it has to retry a few times:
proxy 4730 connect to server failed: Interrupted system call,SSL wants + a read first at ./proxy line 110. proxy 4730 will retry proxy 4730 connected to server
I'm not seeing this against all hosts, which leads me to believe that there may be something strange going on at the far end, but I'd rather have some input from people who have done this sort of thing before I start pointing fingers.

# uname -a Linux redacted 4.6.0-kali1-amd64 #1 SMP Debian 4.6.4-1kali1 (2016-07-2 +1) x86_64 GNU/Linux This is perl 5, version 22, subversion 2 (v5.22.2) built for x86_64-li +nux-gnu-thread-multi IO::Socket::SSL 2.037 Net::SSLeay 1.77
Interestingly, IO::Socket::SSL debugging seems to indicate it is 'ignoring' this as a 'less severe local error' but in fact the connection fails:
DEBUG: .../IO/Socket/SSL.pm:753: done Net::SSLeay::connect -> -1 DEBUG: .../IO/Socket/SSL.pm:763: ssl handshake in progress DEBUG: ...5.22/IO/Socket.pm:48: ignoring less severe local error 'IO:: +Socket::IP configuration failed', keep 'SSL wants a read first' DEBUG: .../IO/Socket/SSL.pm:2777: free ctx 44390832 open=44390832 4401 +1664 43990720 DEBUG: .../IO/Socket/SSL.pm:2782: free ctx 44390832 callback DEBUG: .../IO/Socket/SSL.pm:2789: OK free ctx 44390832 proxy 4824 connect to server failed: Interrupted system call,SSL wants + a read first at ./proxy line 110.
Any thoughts on how to fix this?

-- FloydATC

I got 99 problems, most of them have to do with printers.


In reply to IO::Socket::SSL sometimes says 'SSL wants a read first' by FloydATC

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.