FloydATC has asked for the wisdom of the Perl Monks concerning the following question:
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:
And here is a typical result. Sometimes it will work the first time, sometimes it has to retry a few times:# 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 +"; } }
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.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
Interestingly, IO::Socket::SSL debugging seems to indicate it is 'ignoring' this as a 'less severe local error' but in fact the connection fails:# 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
Any thoughts on how to fix this?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.
I got 99 problems, most of them have to do with printers.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IO::Socket::SSL sometimes says 'SSL wants a read first'
by salva (Canon) on Apr 20, 2017 at 07:29 UTC | |
by FloydATC (Deacon) on Apr 20, 2017 at 15:40 UTC | |
by salva (Canon) on Apr 20, 2017 at 17:22 UTC | |
by noxxi (Pilgrim) on Apr 20, 2017 at 19:41 UTC | |
by salva (Canon) on Apr 20, 2017 at 20:22 UTC | |
| |
|
Re: IO::Socket::SSL sometimes says 'SSL wants a read first'
by zentara (Cardinal) on Apr 20, 2017 at 16:23 UTC | |
|
Re: IO::Socket::SSL sometimes says 'SSL wants a read first'
by noxxi (Pilgrim) on Apr 20, 2017 at 19:28 UTC | |
|
Re: IO::Socket::SSL sometimes says 'SSL wants a read first'
by Anonymous Monk on Apr 20, 2017 at 18:28 UTC |