Crypt-SSLeay
view release on metacpan or search on metacpan
Once you have downloaded and extracted it, `Crypt::SSLeay` installs easily using the standard build process:
perl Makefile.PL
make
make test
make install
Alternatively, you can use [cpanm](https://metacpan.org/pod/App::cpanminus):
cpanm Crypt::SSLeay
If you have OpenSSL headers and libraries in nonstandard locations, you can use
$ perl Makefile.PL --incpath=... --libpath=...
If you would like to use "cpanm" with such custom locations, you can do
$ OPENSSL_INCLUDE=... OPENSSL_LIB=... cpanm Crypt::SSLeay
or, on Windows,
> set OPENSSL_INCLUDE=...
> set OPENSSL_LIB=...
> cpanm Crypt::SSLeay
If you are on Windows, and using a MinGW distribution bundled with ActiveState Perl or Strawberry Perl, you would use `dmake` rather than `make`. If you are using Microsoft's build tools, you would use `nmake`.
For unattended (batch) installations, to be absolutely certain that Makefile.PL does not prompt for questions on STDIN, set the environment variable `PERL_MM_USE_DEFAULT=1` as with any CPAN module built using `ExtUtils::MakeMaker`.
#### VMS
I do not have any experience with VMS. If OpenSSL headers and libraries are not in standard locations searched by your build system by default, please set things up so that they are. If you have generic instructions on how to do it, please open a tic...
## Proxy Support
`LWP::UserAgent` and `Crypt::SSLeay` have their own versions of proxy support. Please read these sections to see which one is appropriate.
### `LWP::UserAgent` proxy support
`LWP::UserAgent` has its own methods of proxying which may work for you and is likely to be incompatible with `Crypt::SSLeay` proxy support. To use `LWP::UserAgent` proxy support, try something like:
my $ua = LWP::UserAgent->new;
$ua->proxy([qw( https http )], "$proxy_ip:$proxy_port");
At the time of this writing, libwww v5.6 seems to proxy https requests fine with an Apache mod_proxy server. It sends a line like:
GET https://www.example.com HTTP/1.1
to the proxy server, which is not the `CONNECT` request that some proxies would expect, so this may not work with other proxy servers than mod_proxy. The `CONNECT` method is used by `Crypt::SSLeay`'s internal proxy support.
### `Crypt::SSLeay` proxy support
For native `Crypt::SSLeay` proxy support of https requests, you need to set the environment variable `HTTPS_PROXY` to your proxy server and port, as in:
# proxy support
$ENV{HTTPS_PROXY} = 'http://proxy_hostname_or_ip:port';
$ENV{HTTPS_PROXY} = '127.0.0.1:8080';
Use of the `HTTPS_PROXY` environment variable in this way is similar to `LWP::UserAgent->env_proxy()` usage, but calling that method will likely override or break the `Crypt::SSLeay` support, so do not mix the two.
Basic authentication credentials to the proxy server can be provided this way:
# proxy_basic_auth
$ENV{HTTPS_PROXY_USERNAME} = 'username';
$ENV{HTTPS_PROXY_PASSWORD} = 'password';
For an example of LWP scripting with `Crypt::SSLeay` native proxy support, please look at the `eg/lwp-ssl-test` script in the `Crypt::SSLeay` distribution.
## Client Certificate Support
Client certificates are supported. PEM encoded certificate and private key files may be used like this:
$ENV{HTTPS_CERT_FILE} = 'certs/notacacert.pem';
$ENV{HTTPS_KEY_FILE} = 'certs/notacakeynopass.pem';
You may test your files with the `eg/net-ssl-test` program, bundled with the distribution, by issuing a command like:
perl eg/net-ssl-test -cert=certs/notacacert.pem \
-key=certs/notacakeynopass.pem -d GET $HOST_NAME
Additionally, if you would like to tell the client where the CA file is, you may set these.
$ENV{HTTPS_CA_FILE} = "some_file";
$ENV{HTTPS_CA_DIR} = "some_dir";
Note that, if specified, `$ENV{HTTPS_CA_FILE}` must point to the actual certificate file. That is, `$ENV{HTTPS_CA_DIR}` is *not* the path where `$ENV{HTTPS_CA_FILE}` is located.
For certificates in `$ENV{HTTPS_CA_DIR}` to be picked up, follow the instructions on http://www.openssl.org/docs/ssl/SSL_CTX_load_verify_locations.html.
There is no sample CA cert file at this time for testing, but you may configure `eg/net-ssl-test` to use your CA cert with the -CAfile option. (TODO: then what is the ./certs directory in the distribution?)
### Creating a test certificate
To create simple test certificates with OpenSSL, you may run the following command:
openssl req -config /usr/local/openssl/openssl.cnf \
-new -days 365 -newkey rsa:1024 -x509 \
-keyout notacakey.pem -out notacacert.pem
To remove the pass phrase from the key file, run:
openssl rsa -in notacakey.pem -out notacakeynopass.pem
### PKCS12 support
The directives for enabling use of PKCS12 certificates is:
$ENV{HTTPS_PKCS12_FILE} = 'certs/pkcs12.pkcs12';
$ENV{HTTPS_PKCS12_PASSWORD} = 'PKCS12_PASSWORD';
Use of this type of certificate takes precedence over previous certificate settings described. (TODO: unclear? Meaning "the presence of this type of certificate"?)
## SSL versions
`Crypt::SSLeay` tries very hard to connect to *any* SSL web server accomodating servers that are buggy, old or simply not standards-compliant. To this effect, this module will try SSL connections in this order:
* SSL v23 : should allow v2 and v3 servers to pick their best type
* SSL v3 : best connection type
* SSL v2 : old connection type
( run in 1.610 second using v1.01-cache-2.11-cpan-39bf76dae61 )