LWP Library Supports HTTPS

This section provides a tutorial example on writing a Perl script to verify HTTPS support of the LWP Library.

If you read the LWP library documentation at https://metacpan.org/pod/LWP, you will see that it is supporting the HTTPS protocol now.

Here is my first test Perl script to verify HTTPS support provided by the LWP library:

#- LWP_HTTPS_Test.pl
#- Copyright (c) 2018 by Dr. Herong Yang, herongyang.com
#
use LWP;
use LWP::UserAgent;
print "This is libwww-perl-$LWP::VERSION\n";

my ($url) = @ARGV;
my $client = LWP::UserAgent->new;
my $request = HTTP::Request->new('GET', 'https://login.yahoo.com');
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>LWP_HTTPS_Test.pl https://login.yahoo.com

This is libwww-perl-6.05

Request:
GET https://login.yahoo.com
User-Agent: libwww-perl/6.05

Response:
HTTP/1.1 200 OK
Cache-Control: nocache, no-store, must-revalidate
Connection: close
Pragma: no-cache
Age: 0
Server: ATS
Vary: Accept-Encoding
Content-Length: 102103
Content-Type: text/html; charset=utf-8
Expires: 0
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=DigiCert Inc/OU=www.digicert.com
   /CN=DigiCert SHA2 High Assurance Server CA
Client-SSL-Cert-Subject: /C=US/ST=California/L=Sunnyvale
   /O=Yahoo Holdings, Inc./CN=*.login.yahoo.com
Client-SSL-Cipher: ECDHE-RSA-AES128-GCM-SHA256
Client-SSL-Socket-Class: IO::Socket::SSL
Referrer-Policy: origin-when-cross-origin
Strict-Transport-Security: max-age=15552000
Title: Yahoo - login
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-Meta-Referrer: origin-when-cross-origin
X-XSS-Protection: 1; mode=block

<!DOCTYPE html>
<html class="no-js">
<head>
...

Here is what I can see from the output:

Table of Contents

 About This Book

 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 Microsoft Edge

 Using HTTPS with Apple Safari

 HTTPS with IE (Internet Explorer)

 Android and Server Certificate

 iPhone 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 Library Supports HTTPS

 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

 S/MIME and Email Security

 PKI (Public Key Infrastructure) Terminology

 Outdated Tutorials

 References

 Full Version in PDF/EPUB