WindowsからCrypt::SSLeayのインストール・詳細版

実は、http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppdppmを使ってCrypt::SSLeayをインストールする場合にはOpenSSLの別途インストールは必要ありません。何故かというと、Crypt::SSLeayで走るスクリプト中でOpenSSLも一緒にインストールすることが出来るから。

ただ、少し注意することが。

  • Crypt::SSLeayのインストールのあと、ssleay32.dll/libleay32.dllのダウンロードに写ります。この2つのDLLがOpenSSL本体です。
  • どこに置くか?と聞かれた時のデフォルトが /Perl/bin と出ますが、このままではダメです。Perlをインストールしたディレクトリの下のbinディレクトリ(perl.exeがあるディレクトリ)をドライブからフルパスで指定してください。

以下が、自分が試してみた時のログです。

  • perlは C:\Perl 以下にインストールしてあります。
  • [..]で囲まれたところの直後で停止してユーザ入力を促します。
    • [..]の中の通りでよい場合はリターンキーだけ押します。
    • [..]とは異なる場合は適宜入力し、リターンキーを押します。
C:\WORK>ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd
====================
Install 'Crypt-SSLeay' version 0.51 in ActivePerl 5.8.4.810.
====================
Installing C:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.bs
Installing C:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.dll
Installing C:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.exp
Installing C:\Perl\site\lib\auto\Crypt\SSLeay\SSLeay.lib
Installing C:\Perl\html\site\lib\Crypt\SSLeay.html
Files found in blib\arch: installing files in blib\lib into architecture depende
nt library tree
Installing C:\Perl\site\lib\Crypt\SSLeay.pm
Installing C:\Perl\site\lib\Crypt\SSLeay\Conn.pm
Installing C:\Perl\site\lib\Crypt\SSLeay\CTX.pm
Installing C:\Perl\site\lib\Crypt\SSLeay\Err.pm
Installing C:\Perl\site\lib\Crypt\SSLeay\MainContext.pm
Installing C:\Perl\site\lib\Crypt\SSLeay\X509.pm
Installing C:\Perl\site\lib\Net\SSL.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]
Fetching http://theoryx5.uwinnipeg.ca/ppms/scripts/ssleay32.dll ...  done!
Where should ssleay32.dll be placed? [/Perl/bin] C:\Perl\bin
ssleay32.dll has been successfully installed to C:/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]
Fetching http://theoryx5.uwinnipeg.ca/ppms/scripts/libeay32.dll ...  done!
Where should libeay32.dll be placed? [/Perl/bin] C:\Perl\bin
libeay32.dll has been successfully installed to C:/Perl/bin
Successfully installed Crypt-SSLeay version 0.51 in ActivePerl 5.8.4.810.

プロキシとかの都合でppmでのインストールが出来ない時は、ppdファイルと以下のファイルをダウンロードして、まずは同じディレクトリに置きます。

でもって、コマンドプロンプトでこのディレクトリに移動し、以下のように入力してCrypt::SSLeayをインストール。

C:\WORK>ppm install Crypt-SSLeay.ppd

ssleay32.dll をダウンロードしにいこうとしたところでCtrl-Cによる強制終了。その後、ssleay32.dllとlibleay32.dllをPerlをインストールしたディレクトリの下のbinディレクトリ(perl.exeがあるディレクトリ)にコピーして終了です。

ちゃんと動作するか確認するには、以下のスクリプトをテキストファイルにしてperlで実行してみてください。HTMLのようなものが表示されれば成功です。Proxy経由の場合は適宜修正してください。

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

# if use proxy, comment out and set:
#$ua->proxy( 'https', "http://proxy-host:proxy-port" );

my $res = $ua->get('https://www.hatena.ne.jp/sslregister');

if ($res->is_success) {
    print $res->content;
}
else {
    die $res->status_line;
}

追記:すんません、確認コード自体間違えてました(泣)あと、URLを変更しました。