Net::SSLeay

Net::SSLeay is a Perl extension for using OpenSSL.
Download

Net::SSLeay Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Mike McCauley and Florian Ragwitz
  • Publisher web site:
  • http://search.cpan.org/~flora/

Net::SSLeay Tags


Net::SSLeay Description

Net::SSLeay is a Perl extension for using OpenSSL. Net::SSLeay is a Perl extension for using OpenSSL.SYNOPSIS use Net::SSLeay qw(get_https post_https sslcat make_headers make_form); ($page) = get_https('www.bacus.pt', 443, '/'); # 1 ($page, $response, %reply_headers) = get_https('www.bacus.pt', 443, '/', # 2 make_headers(User-Agent => 'Cryptozilla/5.0b1', Referer => 'https://www.bacus.pt' )); ($page, $result, %headers) = # 2b = get_https('www.bacus.pt', 443, '/protected.html', make_headers(Authorization => 'Basic ' . MIME::Base64::encode("$user:$pass",'')) ); ($page, $response, %reply_headers) = post_https('www.bacus.pt', 443, '/foo.cgi', '', # 3 make_form(OK => '1', name => 'Sampo' )); $reply = sslcat($host, $port, $request); # 4 ($reply, $err, $server_cert) = sslcat($host, $port, $request); # 5 $Net::SSLeay::trace = 2; # 0=no debugging, 1=ciphers, 2=trace, 3=dump dataThere is a related module called Net::SSLeay::Handle included in this distribution that you might want to use instead. It has its own pod documentation.This module offers some high level convinience functions for accessing web pages on SSL servers (for symmetry, same API is offered for accessing http servers, too), a sslcat() function for writing your own clients, and finally access to the SSL api of SSLeay/OpenSSL package so you can write servers or clients for more complicated applications.For high level functions it is most convinient to import them to your main namespace as indicated in the synopsis.Case 1 demonstrates typical invocation of get_https() to fetch an HTML page from secure server. The first argument provides host name or ip in dotted decimal notation of the remote server to contact. Second argument is the TCP port at the remote end (your own port is picked arbitrarily from high numbered ports as usual for TCP). The third argument is the URL of the page without the host name part. If in doubt consult HTTP specifications at http://www.w3c.org.Case 2 demonstrates full fledged use of get_https(). As can be seen, get_https() parses the response and response headers and returns them as a list, which can be captured in a hash for later reference. Also a fourth argument to get_https() is used to insert some additional headers in the request. make_headers() is a function that will convert a list or hash to such headers. By default get_https() supplies Host (make virtual hosting easy) and Accept (reportedly needed by IIS) headers.Case 2b demonstrates how to get password protected page. Refer to HTTP protocol specifications for further details (e.g. RFC-2617).Case 3 invokes post_https() to submit a HTML/CGI form to secure server. First four arguments are equal to get_https() (note that empty string ('') is passed as header argument). The fifth argument is the contents of the form formatted according to CGI specification. In this case the helper function make_https() is used to do the formatting, but you could pass any string. The post_https() automatically adds Content-Type and Content-Length headers to the request.Case 4 shows the fundamental sslcat() function (inspired in spirit by netcat utility :-). Its your swiss army knife that allows you to easily contact servers, send some data, and then get the response. You are responsible for formatting the data and parsing the response - sslcat() is just a transport.Case 5 is a full invocation of sslcat() which allows return of errors as well as the server (peer) certificate.The $trace global variable can be used to control the verbosity of high level functions. Level 0 guarantees silence, level 1 (the default) only emits error messages. Requirements: · Perl


Net::SSLeay Related Software