vancetech has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl use IO::Socket::INET; use Net::SSLeay qw(die_now die_if_ssl_error ssl_read_all print_errs) ; Net::SSLeay::load_error_strings(); Net::SSLeay::SSLeay_add_ssl_algorithms(); Net::SSLeay::randomize(); $|++; ($dest_serv, $port, $msg) = @ARGV; # Read command line my $sock = IO::Socket::INET->new( Proto => 'tcp', Type => SOCK_STREAM, Blocking => 0 ); $sock->connect( $port, inet_aton($dest_serv) ); $ctx = Net::SSLeay::CTX_new() or die_now("Failed to create SSL_CTX $!" +); Net::SSLeay::CTX_set_options($ctx, &Net::SSLeay::OP_ALL) and die_if_ssl_error("ssl ctx set options"); $ssl = Net::SSLeay::new($ctx) or die_now("Failed to create SSL $!"); Net::SSLeay::set_fd($ssl, fileno($sock)); $res = Net::SSLeay::connect($ssl) and die_if_ssl_error("ssl connect"); print "Cipher `" . Net::SSLeay::get_cipher($ssl) . "'\n"; $res = Net::SSLeay::write($ssl, "GET / HTTP/1.1\nHOST: $dest_serv\n\n" +); die_if_ssl_error("ssl write"); CORE::shutdown $sock, 1; $got = Net::SSLeay::ssl_read_all($ssl); die_if_ssl_error("ssl read"); Net::SSLeay::free ($ssl); Net::SSLeay::CTX_free ($ctx); close $sock; print $got;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::SSLeay and file descriptors
by Anonymous Monk on Sep 13, 2006 at 07:35 UTC | |
by vancetech (Beadle) on Sep 16, 2006 at 00:49 UTC |