Crypt::SSLeay Test Perl Script

This section provides a tutorial example on writing a Perl script to test the Crypt::SSLeay module. The script is executed on Yahoo login HTTPS server.

To test the Crypt::SSLeay module, I wrote the following test Perl script based on the Crypt::SSLeay documentation:

#- Crypt_SSLeay_HTTPS_GET.pl
#- Copyright (c) 2011, HerongYang.com, All Rights Reserved.
#
use LWP::UserAgent;
$ENV{HTTPS_DEBUG} = 1;

my ($url) = @ARGV;
my $client = LWP::UserAgent->new;
my $request = HTTP::Request->new('GET', $url);
my $response = $client->request($request);
$response->is_success or
    die "Failed to GET '$url': ", $response->status_line;

print "Request:\n";
print $request->as_string;
print "Response:\n";
print $response->as_string;

Now let's run this script to connect the yahoo login HTTPS server, which we have used in previous tutorials with Internet Explorer and Firefox Web browsers.

C:\herong>Crypt_SSLeay_HTTPS_GET.pl https://login.yahoo.com 
   > test_yahoo.txt

SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:SSLv3 read finished A

Those debugging messages confirm that my Perl client program received the server certificate and delivered a secret key to the server to encrypt data content exchanged with the server.

Noticed that I redirected the test Perl script to a file, test_yahoo.txt, which contains the request message and the response message. Read the next tutorial for more discussions.

Last update: 2011.

Table of Contents

 About This Book

 Introduction of PKI (Public Key Infrastructure)

 Introduction of HTTPS (Hypertext Transfer Protocol Secure)

 Using HTTPS with IE (Internet Explorer) 10

 Using HTTPS with Chrome 40

 Using HTTPS with Firefox 35

Perl Scripts Communicating with HTTPS Servers

 Installing Crypt::SSLeay 0.57 on Windows

Crypt::SSLeay Test Perl Script

 HTTPS Request and Response Example

 Asking Crypt::SSLeay to Verify Server's Certificate

 Crypt::SSLeay Failing to Verify Server's Certificate

 Multiple CA Certificates in a Single File

 PHP Scripts Communicating with HTTPS Servers

 Java Programs Communicating with HTTPS Servers

 Certificate Stores and Certificate Console

 .NET Programs Communicating with HTTPS Servers

 CAcert.org - Root CA Offering Free Certificates

 PKI CA Administration - Issuing Certificates

 Digital Signature - Microsoft Word 2007

 Digital Signature - OpenOffice.org 3

 S/MIME and Email Security

 PKI (Public Key Infrastructure) Terminology

 Outdated Tutorials

 References

 PDF Printing Version