John Bokma Perl
freelance Perl programmer

HTTPS protocol with ActiveState Perl

Installation and example test program | 52 comments

If you want to access URIs that use the https protocol via Perl you need to install SSL support. ActiveState's repository has no SSL Perl module(s) available so you can't install it using the default settings with ppm. A solution is to use the excellent Perl repository of the University of Winnipeg.

Installation of Crypt::SSLeay

The following lines are a copy of an installation of Crypt::SSLeay which adds the support for the https protocol by downloading the required files from the University of Winnipeg repository. I installed ActivePerl on my D: drive hence the change of the default location for the DLLs. The operating system is Windows 2000 Professional running Perl 5.8.0 build 806 by ActiveState (ActivePerl builds 8xx). If you're using Perl 5.6.x (ActivePerl builds 6xx) make sure that you use http://theoryx5.uwinnipeg.ca/ppmpackages/Crypt-SSLeay.ppd to install from.

ppm> install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd
====================
Install 'Crypt-SSLeay' version 0.51 in ActivePerl 5.8.0.806.
====================
Downloaded 29927 bytes.
Extracting 15/15: blib/html/site/lib/Crypt/SSLeay.html
Installing D:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.bs
Installing D:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.dll
Installing D:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.exp
Installing D:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.lib
Installing D:\Perl\html\site\lib\Crypt\SSLeay.html
Installing D:\Perl\site\lib\Net\SSL.pm
Installing D:\Perl\site\lib\Crypt\SSLeay.pm
Installing D:\Perl\site\lib\Crypt\SSLeay\Conn.pm
Installing D:\Perl\site\lib\Crypt\SSLeay\CTX.pm
Installing D:\Perl\site\lib\Crypt\SSLeay\Err.pm
Installing D:\Perl\site\lib\Crypt\SSLeay\MainContext.pm
Installing D:\Perl\site\lib\Crypt\SSLeay\X509.pm

The library ssleay32.dll is needed to complete the installation,
and should be placed in a directory somewhere in your PATH
environment variable. I can fetch and install this for you,
if you don't already have it.

Fetch ssleay32.dll? [yes] yes
Fetching http://theoryx5.uwinnipeg.ca/ppms/scripts/ssleay32.dll
...  done!
Where should ssleay32.dll be placed? [/Perl/bin] D:/Perl/bin
ssleay32.dll has been successfully installed to D:/Perl/bin

The library libeay32.dll is needed to complete the installation,
and should be placed in a directory somewhere in your PATH
environment variable. I can fetch and install this for you,
if you don't already have it.

Fetch libeay32.dll? [yes] yes
Fetching http://theoryx5.uwinnipeg.ca/ppms/scripts/libeay32.dll
...  done!
Where should libeay32.dll be placed? [/Perl/bin] D:/Perl/bin
libeay32.dll has been successfully installed to D:/Perl/bin
Successfully installed Crypt-SSLeay version 0.51 in ActivePerl
5.8.0.806.
ppm>

Example https test program

After installation of the Crypt::SSLeay module and required DLLs, the following example Perl program should no longer produce 501 Protocol scheme 'https' is not supported but return an HTML page instead:

# https-test.pl - HTTPS GET example
#
#  Copyright, 2004-2005 By John Bokma, http://johnbokma.com/
#
# $Id: https-test.pl 1081 2008-09-30 19:03:23Z john $ 

use strict;
use warnings;


use LWP::UserAgent;

my $url = 'https://www.helsinki.fi/';

my $ua = LWP::UserAgent->new;
my $response = $ua->get( $url );

$response->is_success or
    die "Failed to GET '$url': ", $response->status_line;

print $response->as_string;

A version of Perl for Microsoft Windows (Win32) operating systems can be downloaded from the ActiveState website.

Related

Please post a comment | read 52 comments, latest by amdpp | RSS feed