On Thursday, June 07, 2012 04:07:15 PM you wrote:
Show quoted text> Thu Jun 07 16:07:14 2012: Request 77689 was acted upon.
> Transaction: Ticket created by JSM
> Queue: Net-SSLeay
> Subject: (No subject given)
> Broken in: (no value)
> Severity: Important
> Owner: Nobody
> Requestors: james@jmarshall.com
> Status: new
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=77689 >
>
>
> Many people, myself included, want to use non-blocking I/O with SSL.
> Some people have nice writeups how to do it, but each one I've seen
> comes with unacceptable limitations. This is currently a major hole in
> Perl network programming.
>
> So my main feature request would be a simple-as-possible, official
> description of what exactly must be done for non-blocking I/O, which
> error codes need to be checked where, etc. I'm happy to help with this
> writeup if I can get the needed information.
OK, I have used Net::SSLeay in an number of async non-blocking applications,
using both UDP and TCP based comms. So I know it works, but I do grant that
its hard to figure out how to do it right.
Show quoted text>
> At the moment I think I'd have a solution, if I could only get the
> return code from SSL_read() (Net::SSLeay::read() only returns the gotten
> data). I need this return code to use with Net::SSLeay::get_error(), to
> detect SSL_ERROR_WANT_READ and the other error codes. Is there a way to
> get this return code from SSL_read()? If not, could we perhaps add it
> to the return value of Net::SSLeay::read(), i.e. return a two-item array
> when wantarray?
during the handshake phase, I use
my $ret = &Net::SSLeay::connect($object->{ssl_streamtls});
my $reason = &Net::SSLeay::get_error($object->{ssl_streamtls}, $ret);
my $state = &Net::SSLeay::get_state($object->{ssl_streamtls});
to get the state of the connection
and then:
if ($ret == 1)
{
# Success, the SSL accept has completed successfully,
# therefore the client has verified credentials.
# However, there may be some more data in the output
# BIO to send to the client, so we defer the ACCEPT
# until it is acked
$object->{handshake_finished}++;
}
elsif ($ret == 0)
{
# Handshake was not successful
$object->log($main::LOG_ERR, "client Handshake unsuccessful: "
. &Net::SSLeay::print_errs());
$object->stream_disconnected();
return;
}
elsif ( $reason == Net::SSLeay::ERROR_WANT_READ
|| $reason == Net::SSLeay::ERROR_WANT_WRITE)
{
# Looking for more read or write data, object will provide it when its
available
}
else
{
# Error
$object->log($main::LOG_ERR, "client error: $ret, $reason, $state, "
. &Net::SSLeay::print_errs());
$object->stream_disconnected();
return;
}
after handshake is finished:
$data = &Net::SSLeay::BIO_read($self->{wbio}, $self->{MaxBufferSize});
Show quoted text>
> Also, improving the documentation on error-handling in Net::SSLeay would
> yield great benefits, I think. Again, I'm willing to help with this if
> I can get the needed info-- e.g. what's the deal with $! ? How should
> die_now(), die_if_ssl_error(), and print_errs() be called, and what are
> their return values?
Recent versions of net-ssleay have significantly improved doc'n on these
topics, thanks to KMX. Check the latest version for updates,
Show quoted text>
> Thanks very much for any help. I'm currently stuck on this.
Hope that is helpful.
I will be happy to aply any suitable patches you may send.
--
Mike McCauley mikem@open.com.au
Open System Consultants Pty. Ltd
9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.open.com.au
Phone +61 7 5598-7474 Fax +61 7 5598-7070
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. SQL, proxy, DBM, files, LDAP, NIS+, password, NT, Emerald,
Platypus, Freeside, TACACS+, PAM, external, Active Directory, EAP, TLS,
TTLS, PEAP, TNC, WiMAX, RSA, Vasco, Yubikey, MOTP, HOTP, TOTP,
DIAMETER etc. Full source on Unix, Windows, MacOSX, Solaris, VMS, NetWare etc.