Hi, I'm using the Net::SSLeay perl module to connect to a site over HTTPS and which also implements certificates. I was originally using 'post_https()' and got that to work - though I did have to fix it's prototype in SSLeay.pm. However, as far as I can gather this doesn't use nonblocking sockets. So I've started writing it using the lower level API, and have tried to implement nonblocking sockets. However, I don't think I've done it correctly. If someone could glance over this code and let me know where I;ve gone wrong, that would be most helpful. Note the code below works fine when I don't try to make the socket nonblocking, and it also contains a lot more error checking than pasted here!
Thanks, Stella my $sin = sockaddr_in($port, $dest_ip); my $proto = getprotobyname('tcp'); if (socket (SSLCAT_S, &PF_INET, &SOCK_STREAM, $proto)) { if (CORE::connect (SSLCAT_S, $sin)) { my $old_out = select (SSLCAT_S); $| = 1; select ($old_out); $flags = fcntl(SSLCAT_S, F_GETFL, 0); fcntl(SSLCAT_S, F_SETFL, $flags | O_NONBLOCK); $got = 1; } } else { close SSLCAT_S; return undef; } Net::SSLeay::load_error_strings(); Net::SSLeay::SSLeay_add_ssl_algorithms(); Net::SSLeay::randomize(); my $ctx = Net::SSLeay::CTX_new(); Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL); Net::SSLeay::set_cert_and_key($ctx, $self->{_cert}, $self->{_key}); my $ssl = Net::SSLeay::new($ctx); Net::SSLeay::set_fd($ssl, fileno(SSLCAT_S)); $got = Net::SSLeay::connect($ssl); my $server_cert = Net::SSLeay::get_peer_certificate($ssl); my($written, $errs) = Net::SSLeay::ssl_write_all($ssl, $request); ($got, $errs) = Net::SSLeay::ssl_read_all($ssl); Net::SSLeay::X509_free($server_cert) if defined $server_cert; Net::SSLeay::free($ssl); Net::SSLeay::CTX_free($ctx); close SSLCAT_S; ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]