• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

certs/H24-Apr-2014-4,4874,400

eg/H24-Apr-2014-205153

inc/IO/Interactive/H24-Apr-2014-3415

lib/H24-Apr-2014-840449

t/H24-Apr-2014-485381

ChangesH A D24-Apr-201426 KiB787522

MANIFESTH A D24-Apr-2014651 3331

MANIFEST.SKIPH A D22-Apr-2014240 2018

META.jsonH A D24-Apr-20141.5 KiB6968

META.ymlH A D24-Apr-2014894 4443

Makefile.PLH A D24-Apr-20149 KiB349275

README.mdH A D24-Apr-201414.8 KiB353191

SSLeay.pmH A D24-Apr-201417.1 KiB53936

SSLeay.xsH A D03-May-202214.3 KiB578449

TODOH A D30-Jul-2012200 74

openssl-version.cH A D04-Apr-2014161 97

typemapH A D30-Jul-20121 KiB3932

README.md

1# Crypt::SSLeay - OpenSSL support for LWP
2
3## Do you need Crypt::SSLeay?
4
5Since version 6.02, [LWP](https://metacpan.org/pod/LWP) depends on [LWP::Protocol::https](https://metacpan.org/pod/LWP::Protocol::https) which pulls in [IO::Socket::SSL](https://metacpan.org/pod/IO::Socket::SSL) which is then automatically used by [LWP::UserAgent](https://metacpan.org/pod/LWP::UserAgent) unless you explicitly override it. So, you might no longer need `Crypt::SSLeay`. `IO::Socket::SSL` is preferable anyway because it allows hostname verification which `Crypt::SSLeay` does not support.
6
7At this point, `Crypt::SSLeay` is maintained to support existing software that already depends on it. However, it is possible that your software does not really depend on `Crypt::SSLeay`, only on the ability of `LWP::UserAgent` to communicate with sites over SSL/TLS.
8
9If you have both `Crypt::SSLeay` and `IO::Socket::SSL` installed, and would like to force `LWP::UserAgent` to use `Crypt::SSLeay`, you can use:
10
11    use Net::HTTPS;
12    $Net::HTTPS::SSL_SOCKET_CLASS = 'Net::SSL';
13    use LWP::UserAgent;
14
15or
16
17    local $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = 'Net::SSL';
18    use LWP::UserAgent;
19
20or
21
22    use Net::SSL;
23    use LWP::UserAgent;
24
25## OpenSSL Heartbleed Bug
26
27`perl Makefile.PL` will show a warning if the version of OpenSSL against which you are building `Crypt::SSLeay` seems vulnerable to the [Heartbleed Bug](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160). See my blog post [Is a strong caution about Heartbleed worth the disruption to distributions with a declared dependency on Crypt::SSLeay?](http://blog.nu42.com/2014/04/is-strong-caution-about-heartbleed.html) for the reasoning behind this.
28
29## Synopsis
30
31    use Net::SSL;
32    use LWP::UserAgent;
33
34    my $ua  = LWP::UserAgent->new(
35        ssl_opts => { verify_hostname => 0 },
36    );
37
38    my $response = $ua->get('https://www.example.com/');
39    print $response->content, "\n";
40
41## Description
42
43This Perl module provides support for the HTTPS protocol under LWP, to allow an `LWP::UserAgent` object to perform GET, HEAD and POST requests.  Please see [LWP](https://metacpan.org/pod/LWP) for more information on POST requests.
44
45The `Crypt::SSLeay` package provides `Net::SSL`, which is loaded by `LWP::Protocol::https` for https requests and provides the necessary SSL glue.
46
47This distribution also makes following deprecated modules available:
48
49    Crypt::SSLeay::CTX
50    Crypt::SSLeay::Conn
51    Crypt::SSLeay::X509
52
53Work on Crypt::SSLeay has been continued only to provide https support for the LWP (libwww-perl) libraries.
54
55## Environment Variables
56
57The following environment variables change the way `Crypt::SSLeay` and `Net::SSL` behave.
58
59### Specify SSL Socket Class
60
61    $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}
62
63can be used to instruct `LWP::UserAgent` to use `Net::SSL` for HTTPS support rather than `IO::Socket::SSL`.
64
65### Proxy Support
66
67    $ENV{HTTPS_PROXY} = 'http://proxy_hostname_or_ip:port';
68
69### Proxy Basic Authentication
70
71    $ENV{HTTPS_PROXY_USERNAME} = 'username';
72    $ENV{HTTPS_PROXY_PASSWORD} = 'password';
73
74### SSL Diagnostics and Debugging
75
76    $ENV{HTTPS_DEBUG} = 1;
77
78### Default SSL Version
79
80    $ENV{HTTPS_VERSION} = '3';
81
82### Client Certificate Support
83
84    $ENV{HTTPS_CERT_FILE} = 'certs/notacacert.pem';
85    $ENV{HTTPS_KEY_FILE}  = 'certs/notacakeynopass.pem';
86
87### CA cert peer verification
88
89    $ENV{HTTPS_CA_FILE}   = 'certs/ca-bundle.crt';
90    $ENV{HTTPS_CA_DIR}    = 'certs/';
91
92### Client PKCS12 cert support
93
94    $ENV{HTTPS_PKCS12_FILE}     = 'certs/pkcs12.pkcs12';
95    $ENV{HTTPS_PKCS12_PASSWORD} = 'PKCS12_PASSWORD';
96
97## Installation
98
99### OpenSSL
100
101You must have OpenSSL installed before compiling this module. You can get the latest OpenSSL package from [OpenSSL.org](https://www.openssl.org/source/). We no longer support pre-2000 versions of OpenSSL.
102
103If you are building OpenSSL from source, please follow the directions included in the source package.
104
105### Crypt::SSLeay via Makefile.PL
106
107`Makefile.PL` accepts the following command line arguments:
108
109
110#### incpath
111
112Path to OpenSSL headers. Can also be specified via `$ENV{OPENSSL_INCLUDE}`. If the command line argument is provided, it overrides any value specified via the environment variable. Of course, you can ignore both the command line argument and the environment variable, and just add the path to your compiler specific environment variable such as `CPATH` or `INCLUDE` etc.
113
114#### libpath
115
116Path to OpenSSL libraries. Can also be specified via `$ENV{OPENSSL_LIB}`. If the command line argument is provided, it overrides any value specified by the environment variable. Of course, you can ignore both the command line argument and the environment variable and just add the path to your compiler specific environment variable such as `LIBRARY_PATH` or `LIB` etc.
117
118#### live-tests
119
120Use `--live-tests` to request tests that try to connect to an external web site, and "--no-live_tests" to prevent such tests from running. If you run `Makefile.PL` interactively, and this argument is not specified on the command line, you will be prompted for a value.
121
122Default is false.
123
124
125#### static
126
127Boolean. Default is false. TODO: How is this even supposed to work?
128
129#### verbose
130
131Boolean. Default is false. If you pass `--verbose` on the command line, both "Devel::CheckLib" and "ExtUtils::CBuilder" instances will be configured to echo what they are doing.
132
133If everything builds OK, but you get failures when during tests, ensure that `LD_LIBRARY_PATH`is pointing to the location where the correct shared libraries are located.
134
135### Crypt::SSLeay
136
137The latest `Crypt::SSLeay` can be found at your nearest CPAN, as well as on [metacpan](https://metacpan.org/dist/Crypt::SSLeay).
138
139Once you have downloaded and extracted it, `Crypt::SSLeay` installs easily using the standard build process:
140
141    perl Makefile.PL
142    make
143    make test
144    make install
145
146Alternatively, you can use [cpanm](https://metacpan.org/pod/App::cpanminus):
147
148    cpanm Crypt::SSLeay
149
150If you have OpenSSL headers and libraries in nonstandard locations, you can use
151
152    $ perl Makefile.PL --incpath=... --libpath=...
153
154If you would like to use "cpanm" with such custom locations, you can do
155
156    $ OPENSSL_INCLUDE=... OPENSSL_LIB=... cpanm Crypt::SSLeay
157
158or, on Windows,
159
160    > set OPENSSL_INCLUDE=...
161    > set OPENSSL_LIB=...
162    > cpanm Crypt::SSLeay
163
164If 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`.
165
166For 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`.
167
168#### VMS
169
170I 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 ticket on RT with the information so I can add it to this document.
171
172## Proxy Support
173
174`LWP::UserAgent` and `Crypt::SSLeay` have their own versions of proxy support.  Please read these sections to see which one is appropriate.
175
176### `LWP::UserAgent` proxy support
177
178`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:
179
180    my $ua = LWP::UserAgent->new;
181    $ua->proxy([qw( https http )], "$proxy_ip:$proxy_port");
182
183At 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:
184
185    GET https://www.example.com HTTP/1.1
186
187to 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.
188
189### `Crypt::SSLeay` proxy support
190
191For 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:
192
193    # proxy support
194    $ENV{HTTPS_PROXY} = 'http://proxy_hostname_or_ip:port';
195    $ENV{HTTPS_PROXY} = '127.0.0.1:8080';
196
197Use 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.
198
199Basic authentication credentials to the proxy server can be provided this way:
200
201    # proxy_basic_auth
202    $ENV{HTTPS_PROXY_USERNAME} = 'username';
203    $ENV{HTTPS_PROXY_PASSWORD} = 'password';
204
205For 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.
206
207## Client Certificate Support
208
209Client certificates are supported. PEM encoded certificate and private key files may be used like this:
210
211    $ENV{HTTPS_CERT_FILE} = 'certs/notacacert.pem';
212    $ENV{HTTPS_KEY_FILE}  = 'certs/notacakeynopass.pem';
213
214You may test your files with the `eg/net-ssl-test` program, bundled with the distribution, by issuing a command like:
215
216    perl eg/net-ssl-test -cert=certs/notacacert.pem \
217        -key=certs/notacakeynopass.pem -d GET $HOST_NAME
218
219Additionally, if you would like to tell the client where the CA file is, you may set these.
220
221        $ENV{HTTPS_CA_FILE} = "some_file";
222        $ENV{HTTPS_CA_DIR}  = "some_dir";
223
224Note 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.
225
226For 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.
227
228There 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?)
229
230### Creating a test certificate
231
232To create simple test certificates with OpenSSL, you may run the following command:
233
234    openssl req -config /usr/local/openssl/openssl.cnf \
235        -new -days 365 -newkey rsa:1024 -x509 \
236        -keyout notacakey.pem -out notacacert.pem
237
238To remove the pass phrase from the key file, run:
239
240    openssl rsa -in notacakey.pem -out notacakeynopass.pem
241
242### PKCS12 support
243
244The directives for enabling use of PKCS12 certificates is:
245
246    $ENV{HTTPS_PKCS12_FILE}     = 'certs/pkcs12.pkcs12';
247    $ENV{HTTPS_PKCS12_PASSWORD} = 'PKCS12_PASSWORD';
248
249Use of this type of certificate takes precedence over previous certificate settings described. (TODO: unclear? Meaning "the presence of this type of certificate"?)
250
251## SSL versions
252
253`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:
254
255*   SSL v23 : should allow v2 and v3 servers to pick their best type
256
257*   SSL v3 :  best connection type
258
259*   SSL v2 :  old connection type
260
261Unfortunately, some servers seem not to handle a reconnect to SSL v3 after a failed connect of SSL v23 is tried, so you may set before using LWP or `Net::SSL`:
262
263    $ENV{HTTPS_VERSION} = 3;
264
265to force a version 3 SSL connection first. At this time, only a version 2 SSL connection will be tried after this, as the connection attempt order remains unchanged by this setting.
266
267## Acknowledgements
268
269many thanks to the following individuals who helped improve Crypt-SSLeay:
270
271* _Gisle Aas_ for writing this module and many others including libwww, for Perl. The web will never be the same :)
272
273* _Ben Laurie_ deserves kudos for his excellent patches for better error handling, SSL information inspection, and random seeding.
274
275* _Dongqiang Bai_ for host name resolution fix when using a proxy.
276
277* _Stuart Horner_ of Core Communications, Inc. who found the need for building `--shared` OpenSSL libraries.
278
279* _Pavel Hlavnicka_ for a patch for freeing memory when using a pkcs12 file, and for inspiring more robust `read()` behavior.
280
281* _James Woodyatt_ is a champ for finding a ridiculous memory leak that has been the bane of many a `Crypt::SSLeay` user.
282
283* _Bryan Hart_ for his patch adding proxy support, and thanks to _Tobias Manthey_ for submitting another approach.
284
285* _Alex Rhomberg_ for Alpha linux ccc patch.
286
287* _Tobias Manthey_ for his patches for client certificate support.
288
289* _Daisuke Kuroda_ for adding PKCS12 certificate support.
290
291* _Gamid Isayev_ for CA cert support and insights into error messaging.
292
293* _Jeff Long_ for working through a tricky CA cert SSLClientVerify issue.
294
295* _Chip Turner_ for a patch to build under perl 5.8.0.
296
297* _Joshua Chamas_ for the time he spent maintaining the module.
298
299* _Jeff Lavallee_ for help with alarms on read failures (CPAN bug #12444).
300
301* _Guenter Knauf_ for significant improvements in configuring things in Win32 and Netware lands and Jan Dubois for various suggestions for improvements.
302
303and _many others_ who provided bug reports, suggestions, fixes and patches.
304
305If you have reported a bug or provided feedback, and you would like to be mentioned by name in this section, please file request on [rt.cpan.org](http://rt.cpan.org/NoAuth/Bugs.html?Dist=Crypt-SSLeay).
306
307###	TODO: Update acknowledgements list.
308
309## See Also
310
311*   `Net::SSL`
312
313    If you have downloaded this distribution as of a dependency of
314    another distribution, it's probably due to this module (which is
315    included in this distribution).
316
317*   `Net::SSLeay`
318
319    [Net::SSLeay](https://metacpan.org/pod/Net::SSLeay) provides access to the OpenSSL API directly from Perl.
320
321*   [OpenSSL binary packages for Windows](http://www.openssl.org/related/binaries.html)
322
323*   [IO::Socket::SSL](https://metacpan.org/pod/IO::Socket::SSL)
324
325*   [Building OpenSSL on 64-bit Windows 8.1 Pro using SDK tools](http://blog.nu42.com/2014/04/building-openssl-101g-on-64-bit-windows).
326
327## Support
328
329*   For use of `Crypt::SSLeay` & `Net::SSL` with Perl's LWP, please send email to [libwww@perl.org](mailto:libwww@perl.org).
330
331*   For OpenSSL or general SSL support, including issues associated with building and installing OpenSSL on your system, please email the OpenSSL users mailing list at [openssl-users@openssl.org](mailto:openssl-users@openssl.org). See http://www.openssl.org/support/community.html for other mailing lists and archives.
332
333*   Please report all bugs on [rt.cpan.org](http://rt.cpan.org/NoAuth/Bugs.html?Dist=Crypt-SSLeay).
334
335## Authors
336
337This module was originally written by Gisle Aas, and was subsequently maintained by Joshua Chamas, David Landgren, brian d foy, and A. Sinan Unur.
338
339## Copyright
340
341Copyright © 2010-2014 A. Sinan Unur
342
343Copyright © 2006-2007 David Landgren
344
345Copyright © 1999-2003 Joshua Chamas
346
347Copyright © 1998 Gisle Aas
348
349## License
350
351This program is free software; you can redistribute it and/or modify it under the terms of [Artistic License 2.0](http://www.perlfoundation.org/artistic_license_2_0).
352
353