PKI Tutorials - Herong's Tutorial Examples - v2.32, by Herong Yang
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) 2010-2018 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.
herong> perl 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.
Table of Contents
Introduction of PKI (Public Key Infrastructure)
Introduction of HTTPS (Hypertext Transfer Protocol Secure)
Using HTTPS with Google Chrome
Using HTTPS with Mozilla Firefox
HTTPS with IE (Internet Explorer)
Android and Server Certificate
Windows Certificate Stores and Console
RDP (Remote Desktop Protocol) and Server Certificate
macOS Certificate Stores and Keychain Access
►Perl Scripts Communicating with HTTPS Servers
Installing Crypt::SSLeay 0.72 on Windows
LWP SSL verify_hostname Setting
LWP SSL List of Root CA Certificates
►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
.NET Programs Communicating with HTTPS Servers
CAcert.org - Root CA Offering Free Certificates
PKI CA Administration - Issuing Certificates
Comodo Free Personal Certificate
Digital Signature - Microsoft Word
Digital Signature - OpenOffice.org 3