Revision history for Crypt-SSLeay
=================================
+0.70 2014-04-24 14:53:43 UTC
+
+- RT #94974: I forgot that `return` just returns from the code block for
+ `catch`, not the subroutine so `filter_libs` was still trying to link
+ against various libraries even when Devel::CheckLib was not installed.
+
+0.68 2014-04-24 14:13:07 UTC
+
+- Previous release did not bump version number in Net::SSL even though there
+ was a minor change. Correct that oversight.
+
+0.66 2014-04-24 14:00:42 UTC
+
+- Various minor fixes to C code
+- Various fixes to the distribution such as manifest files, additional
+ tests, bundled module etc
+- Address RT bugs #94828 and #79212
+
+0.65_14 2014-04-16 23:55:42 UTC
+
+- REMINDER: make test WILL FAIL if your OpenSSL is vulnerable to Heartbleed.
+
+- Add additional functions exposing information that can be obtained via
+ SSLeay_version.
+
+0.65_13 2014-04-15 22:22:43 UTC
+
+- Work in progress
+
+- Add ability to query OpenSSL version, add test whether OpenSSL library
+ being used is vulnerable to the Heartbleed bug.
+
+- Assorted fixes to Makefile.PL, most importantly to fix build problems with
+ Strawberry Perl.
+
+0.65_08 2014-04-10 13:40:08 UTC
+
+- Work in progress
+
+- In Makefile.PL, use assert_lib to find the libraries against which we can
+ actually link rather than passing a big bowl of libs to WriteMakefile.
+ Bail out early if we can't link against any of the candidate libraries.
+
+0.65_07 2014-04-10 12:38:06 UTC
+
+- Work in progres
+
+- Make sure t/02-live.t actually uses Net::SSL.
+
+0.65_06 2014-04-10 10:35:14 UTC
+
+- Work in progress
+
+- Address RT bugs #88786, #88269, #78848, and #79477
+
+- Makefile.PL now respects live-tests and no-live-tests, and allows library
+ and header locations to be specified via the command line arguments
+ libpath and incpath, respectively.
+
+- These options can also be specified using the environment variables
+
+ CRYPT_SSLEAY_LIVE_TEST_WANTED
+ OPENSSL_LIB
+ OPENSSL_INC
+
+- Also fixed a number of embarrasing logic errors and typos in Makefile.PL
+ which were introduced in previous 0.65_xx versions.
+
+0.65_05 2014-04-04 12:38:21 UTC
+
+- Work in progress
+
+- Reorganize Makefile.PL to allow incpath and libpath command line
+ arguments. This attempts to address RT #88786, #88269, #79477, and #78848.
+ This was supposed to be the next step immediately after drastically
+ specifying Makefile.PL. But never got done.
+
+- Also add encoded version number to openssl-version output.
+
+0.65_04 2014-04-02 18:03:11 UTC
+
+- Work in progress
+
+- Address pull requests from GitHub and bug reports on RT. These address RT
+ issues #83764, #86425, #86819, #62133, #82715, #90803
+
0.64 2012-08-06 01:23:30
- Drastically simplify Makefile.PL to resolve RT bugs #61249, #61324,
MANIFEST
MANIFEST.SKIP
Makefile.PL
+openssl-version.c
README.md
SSLeay.pm
SSLeay.xs
certs/ca-bundle.crt
certs/notacacert.pem
certs/notacakeynopass.pem
+inc/IO/Interactive/Tiny.pm
lib/Crypt/SSLeay/CTX.pm
lib/Crypt/SSLeay/Conn.pm
lib/Crypt/SSLeay/Err.pm
lib/Crypt/SSLeay/MainContext.pm
lib/Crypt/SSLeay/X509.pm
+lib/Crypt/SSLeay/Version.pm
lib/Net/SSL.pm
eg/lwp-ssl-test
eg/net-ssl-test
t/00-basic.t
t/01-connect.t
t/02-live.t
+t/03-version.t
+t/boilerplate.t
+t/manifest.t
META.yml Module meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
blib\/
\B.svn\b
\B.git\b
+\.DS_Store
pm_to_blib
README.old
crypt_ssleay_version.h
MANIFEST.bak
Makefile$
Makefile.old
+openssl-version
+openssl-version.exe
SSLeay\.(bs|c|o)$
+test.config
^\.gitignore
^\.gitattributes
+^\.travis
"Gisle Aas"
],
"dynamic_config" : 1,
- "generated_by" : "ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921",
+ "generated_by" : "ExtUtils::MakeMaker version 6.96, CPAN::Meta::Converter version 2.140640",
+ "keywords" : [
+ "lwp",
+ "lwp-useragent",
+ "openssl",
+ "https"
+ ],
"license" : [
"artistic_2"
],
"no_index" : {
"directory" : [
"t",
+ "inc",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
- "Test::More" : "0.88",
- "Try::Tiny" : "0.09"
+ "ExtUtils::MakeMaker" : "0",
+ "Test::More" : "0.19",
+ "Try::Tiny" : "0.19"
}
},
"configure" : {
"requires" : {
- "ExtUtils::MakeMaker" : "0"
+ "ExtUtils::CBuilder" : "0.280205",
+ "Getopt::Long" : "0",
+ "Path::Class" : "0.26",
+ "Try::Tiny" : "0.19"
}
},
"runtime" : {
"requires" : {
"LWP::Protocol::https" : "6.02",
- "MIME::Base64" : "0"
+ "MIME::Base64" : "0",
+ "perl" : "5.006"
}
}
},
"release_status" : "stable",
- "version" : "0.64"
+ "resources" : {
+ "repository" : {
+ "url" : "https://github.com/nanis/Crypt-SSLeay"
+ }
+ },
+ "version" : "0.72",
+ "x_build" : {
+ "recommends" : {
+ "Devel::CheckLib" : "0.99"
+ }
+ }
}
- 'Joshua Chamas'
- 'Gisle Aas'
build_requires:
- Test::More: 0.88
- Try::Tiny: 0.09
+ ExtUtils::MakeMaker: '0'
+ Test::More: '0.19'
+ Try::Tiny: '0.19'
configure_requires:
- ExtUtils::MakeMaker: 0
+ ExtUtils::CBuilder: '0.280205'
+ Getopt::Long: '0'
+ Path::Class: '0.26'
+ Try::Tiny: '0.19'
dynamic_config: 1
-generated_by: 'ExtUtils::MakeMaker version 6.62, CPAN::Meta::Converter version 2.120921'
+generated_by: 'ExtUtils::MakeMaker version 6.96, CPAN::Meta::Converter version 2.140640'
+keywords:
+ - lwp
+ - lwp-useragent
+ - openssl
+ - https
license: artistic_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ version: '1.4'
name: Crypt-SSLeay
no_index:
directory:
- t
- inc
+ - inc
requires:
- LWP::Protocol::https: 6.02
- MIME::Base64: 0
-version: 0.64
+ LWP::Protocol::https: '6.02'
+ MIME::Base64: '0'
+ perl: '5.006'
+resources:
+ repository: https://github.com/nanis/Crypt-SSLeay
+version: '0.72'
+x_build:
+ recommends:
+ Devel::CheckLib: '0.99'
+use 5.006;
use strict;
use warnings;
+use ExtUtils::CBuilder;
use ExtUtils::MakeMaker;
-use Getopt::Long;
+use Getopt::Long qw( GetOptionsFromArray );
+use Path::Class;
+use Try::Tiny;
-eval "use ExtUtils::MakeMaker::Coverage";
-$@ or print "Adding testcover target\n";
+use inc::IO::Interactive::Tiny;
-my @authors = reverse ( # reverse chronological order
- 'Gisle Aas',
- 'Joshua Chamas',
- 'David Landgren',
- 'A. Sinan Unur <nanis@cpan.org>',
-);
+caller
+ or run(\@ARGV, [qw{ssl crypto ssl32 ssleay32 eay32 libeay32 z}]);
-my $mm_version = $ExtUtils::MakeMaker::VERSION;
-$mm_version =~ tr/_//d;
+sub run {
+ my $argv = shift;
+ my $libs = shift;
-my ($opt_static, $opt_live_tests);
+ eval "use ExtUtils::MakeMaker::Coverage";
+ $@ or print "Adding testcover target\n";
-GetOptions(
- 'static', \$opt_static,
- 'live-tests!', \$opt_live_tests,
-);
+ my @authors = reverse ( # reverse chronological order
+ 'Gisle Aas',
+ 'Joshua Chamas',
+ 'David Landgren',
+ 'A. Sinan Unur <nanis@cpan.org>',
+ );
-$opt_live_tests ||= $ENV{CRYPT_SSLEAY_LIVE_TEST_WANTED};
-$opt_live_tests ||= is_live_test_wanted();
+ my $mm_version = $ExtUtils::MakeMaker::VERSION;
+ $mm_version =~ tr/_//d;
-my $test_config = 'test.config';
+ my %opt;
+ GetOptionsFromArray(
+ $argv,
+ \%opt,
+ 'incpath=s',
+ 'libpath=s',
+ 'live-tests!',
+ 'static',
+ 'verbose!',
+ ) or die "Error parsing command line options\n";
-WriteMakefile(
- NAME => 'Crypt::SSLeay',
+ if ($ENV{AUTOMATED_TESTING}) {
+ $opt{verbose} = 1;
+ }
+
+ if (
+ (not exists $opt{incpath}) and
+ (exists $ENV{OPENSSL_INCLUDE})
+ )
+ {
+ $opt{incpath} = $ENV{OPENSSL_INCLUDE};
+ }
+
+ if (
+ (not exists $opt{libpath}) and
+ (exists $ENV{OPENSSL_LIB})
+ )
+ {
+ $opt{libpath} = $ENV{OPENSSL_LIB};
+ }
+
+ # Address RT #78848 and RT #88269
+
+ for my $arg (qw(incpath libpath)) {
+ next unless exists $opt{$arg};
+ my $path = $opt{$arg};
+
+ try {
+ $opt{$arg} = file($path)->absolute->resolve
+ }
+ catch {
+ print "Failed to resolve '$arg=$path': $_\n";
+ exit 0;
+ };
+ }
+
+ $libs = filter_libs(\%opt, $libs);
+
+ unless ($ENV{AUTOMATED_TESTING}) {
+ show_do_you_need_crypt_ssleay();
+ }
+
+ my $my_openssl_version_cmd = eval {
+ build_openssl_version(\%opt, 'openssl-version.c');
+ };
+
+ unless (defined $my_openssl_version_cmd) {
+ print "Failed to build and link a simple executable using OpenSSL\n";
+ exit 0;
+ };
+
+ show_cmd_output($my_openssl_version_cmd);
+
+ # No live tests by default
+ if ($ENV{PERL_MM_USE_DEFAULT}) {
+ $opt{'live-tests'} = 0;
+ }
+ # otherwise, only check other ways of requesting live tests if command
+ # line option was not given
+ elsif (not exists $opt{'live-tests'}) {
+ if (exists $ENV{CRYPT_SSLEAY_LIVE_TEST_WANTED}) {
+ $opt{'live-tests'} = $ENV{CRYPT_SSLEAY_LIVE_TEST_WANTED};
+ }
+ elsif (IO::Interactive::Tiny::is_interactive()) {
+ $opt{'live-tests'} = is_live_test_wanted();
+ }
+ }
+
+ my %params = (
+ META_MERGE => {
+ keywords => [ qw(lwp lwp-useragent openssl https) ],
+ no_index => {
+ directory => [ 'inc' ],
+ },
+ build => {
+ recommends => {
+ 'Devel::CheckLib' => '0.99',
+ },
+ },
+ resources => {
+ repository => 'https://github.com/nanis/Crypt-SSLeay',
+ },
+ },
+
+ NAME => 'Crypt::SSLeay',
+
+ AUTHOR => \@authors,
+
+ ABSTRACT_FROM => 'SSLeay.pm',
+
+ VERSION_FROM => 'SSLeay.pm',
+
+ INC => $opt{incpath} ? qq{-I$opt{incpath}} : q{},
+
+ LIBS => $opt{libpath}
+ ? [ join ' ', "-L$opt{libpath}", map "-l$_", @$libs ]
+ : [ join ' ', map "-l$_", @$libs ]
+ ,
+
+ ($opt{static} ? (LINK_TYPE => 'static') : ()),
+
+ TEST_REQUIRES => {
+ 'Try::Tiny' => '0.19',
+ 'Test::More' => '0.19',
+ },
+
+ CONFIGURE_REQUIRES => {
+ 'ExtUtils::CBuilder' => '0.280205',
+ 'Getopt::Long' => 0,
+ 'Path::Class' => '0.26',
+ 'Try::Tiny' => '0.19',
+ },
+
+ PREREQ_PM => {
+ 'LWP::Protocol::https' => '6.02',
+ 'MIME::Base64' => 0, # for Net::SSL
+ },
+
+ clean => {
+ FILES => join(' ',
+ 'test.config',
+ 'openssl-version.o',
+ $my_openssl_version_cmd,
+ 'assertlib*',
+ ),
+ },
- AUTHOR => $mm_version > 6.5701 ? \@authors : $authors[0],
+ LICENSE => 'artistic_2',
- ABSTRACT_FROM => 'SSLeay.pm',
+ MIN_PERL_VERSION => 5.006,
+ );
- VERSION_FROM => 'SSLeay.pm',
+ $mm_version = eval $mm_version;
- LIBS => [q{-lz -lssl -lcrypto -lssl32 -lssleay32 -leay32}],
+ die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
+ die "License not specified" if not exists $params{LICENSE};
- ($opt_static ? (LINK_TYPE => 'static') : ()),
+ if (
+ $params{AUTHOR} and
+ ref($params{AUTHOR}) eq ref([]) and
+ $mm_version < 6.5705
+ ) {
+ $params{META_ADD}->{author} = $params{AUTHOR};
+ $params{AUTHOR}=join(', ', @{$params{AUTHOR}});
+ }
- BUILD_REQUIRES => {
- 'Try::Tiny' => '0.09',
- 'Test::More' => '0.88',
- },
+ if ($params{TEST_REQUIRES} and $mm_version < 6.64) {
+ $params{BUILD_REQUIRES} = {
+ %{ $params{BUILD_REQUIRES} || {} },
+ %{ $params{TEST_REQUIRES} },
+ };
+ delete $params{TEST_REQUIRES};
+ }
- PREREQ_PM => {
- 'LWP::Protocol::https' => '6.02',
- 'MIME::Base64' => 0, # for Net::SSL
- },
+ if ($params{BUILD_REQUIRES} and $mm_version < 6.5503) {
+ #EUMM 6.5502 has problems with BUILD_REQUIRES
+ $params{PREREQ_PM} = {
+ %{ $params{PREREQ_PM} || {} },
+ %{ $params{BUILD_REQUIRES}},
+ };
+ delete $params{BUILD_REQUIRES};
+ }
- clean => {
- FILES => $test_config,
- },
+ delete $params{CONFIGURE_REQUIRES} if $mm_version < 6.52;
+ delete $params{MIN_PERL_VERSION} if $mm_version < 6.48;
+ delete $params{META_MERGE} if $mm_version < 6.46;
+ delete $params{META_ADD} if $mm_version < 6.46;
+ delete $params{LICENSE} if $mm_version < 6.31;
+ delete $params{AUTHOR} if $] < 5.005;
+ delete $params{ABSTRACT_FROM} if $] < 5.005;
+ delete $params{BINARY_LOCATION} if $] < 5.005;
- ($mm_version > 6.3 ? (LICENSE => 'artistic_2') : ()),
-);
+ WriteMakefile(%params);
-write_test_config($test_config, {network_tests => $opt_live_tests});
+ write_test_config('test.config' =>
+ {
+ network_tests => ($opt{'live-tests'} ? 1 : 0),
+ }
+ );
+}
sub is_live_test_wanted {
print <<EO_CHUNK;
}
sub write_test_config {
- my ($file, $config) = @_;
+ my $file = shift;
+ my $config = shift;
- open my $out, '>', $file
- or die "Cannot open '$file' for writing: $!";
+ file($file)->spew(
+ [
+ map sprintf("%s\t%s\n", $_, $config->{$_}), sort keys %$config
+ ]
+ );
+ return;
+}
- for my $key (sort keys %$config) {
- printf $out "%s\t%s\n", $key, $config->{$key};
- }
+sub show_cmd_output {
+ my ($cmd) = @_;
+ my $sep = '=' x 80 . "\n";
+
+ my $output = `$cmd`;
- close $out
- or die "Cannot close '$file': $!";
+ print $sep,
+ defined($output) ? "Output from '$cmd':\n$output"
+ : "No output from '$cmd'",
+ $sep
+ ;
return;
}
+sub build_openssl_version {
+ my $opt = shift;
+ my $source = shift;
+
+ my $builder = ExtUtils::CBuilder->new(quiet => !($opt->{verbose} ? 1 : 0));
+
+ my $object = $builder->compile(
+ source => $source,
+ $opt->{incpath} ? (include_dirs => "$opt->{incpath}") : (),
+ );
+
+ my $executable = $builder->link_executable(
+ objects => $object,
+ );
+
+ return file($executable)->absolute->resolve;
+}
+
+sub filter_libs {
+ my $opt = shift;
+ my $libs = shift;
+
+ return $libs unless eval {
+ require Devel::CheckLib;
+ Devel::CheckLib->import;
+ 1;
+ };
+
+ my @found;
+
+ for my $lib (@$libs) {
+ eval {
+ assert_lib(
+ debug => ($opt->{verbose} ? 1 : 0),
+ lib => $lib,
+ header => 'openssl/ssl.h',
+ $opt->{libpath} ? (libpath => "$opt->{libpath}") : (),
+ $opt->{incpath} ? (incpath => "$opt->{incpath}") : (),
+ );
+ push @found, $lib;
+ };
+ }
+ unless (grep /crypt|ssl|eay/, @found) {
+ printf(
+ "Cannot link with any of the requested SSL libraries '%s'\n",
+ join(', ' => @$libs),
+ );
+ exit 0;
+ }
+
+ printf "Found libraries '%s'\n", join(', ' => @found);
+ return \@found;
+}
+
+sub show_do_you_need_crypt_ssleay {
+ print <<EO_DO_YOU_NEED_CRYPT_SSLEAY;
+
+ *** THIS IS NOT AN ERROR, JUST A MESSAGE FOR YOUR INFORMATION ***
+
+ Do you really need Crypt::SSLeay?
+
+ Starting with version 6.02 of LWP, https support was unbundled into
+ LWP::Protocol::https. This module specifies as one of its prerequisites
+ IO::Socket::SSL which is automatically used by LWP::UserAgent unless
+ this preference is overridden separately. IO::Socket::SSL is a more
+ complete implementation, and, crucially, it allows hostname
+ verification. Crypt::SSLeay does not support this. At 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 class to
+ communicate with sites over SSL/TLS.
+
+ If are using version LWP 6.02 or later, and therefore have installed
+ LWP::Protocol::https and its dependencies, and do not explicitly use
+ Net::SSL before loading LWP::UserAgent, or override the default socket
+ class, you are probably using IO::Socket::SSL and do not really need
+ Crypt::SSLeay.
+
+ Before installing Crypt::SSLeay, you may want to try specifying a
+ dependency on LWP::Protocol::https.
+
+EO_DO_YOU_NEED_CRYPT_SSLEAY
+}
# Crypt::SSLeay - OpenSSL support for LWP
-## Synopsis
+## Do you need Crypt::SSLeay?
+
+Since 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.
+
+At 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.
+
+If you have both `Crypt::SSLeay` and `IO::Socket::SSL` installed, and would like to force `LWP::UserAgent` to use `Crypt::SSLeay`, you can use:
+
+ use Net::HTTPS;
+ $Net::HTTPS::SSL_SOCKET_CLASS = 'Net::SSL';
+ use LWP::UserAgent;
+
+or
+
+ local $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = 'Net::SSL';
+ use LWP::UserAgent;
- lwp-request https://www.example.com
+or
+ use Net::SSL;
use LWP::UserAgent;
- my $ua = LWP::UserAgent->new;
+
+## OpenSSL Heartbleed Bug
+
+`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.
+
+## Synopsis
+
+ use Net::SSL;
+ use LWP::UserAgent;
+
+ my $ua = LWP::UserAgent->new(
+ ssl_opts => { verify_hostname => 0 },
+ );
+
my $response = $ua->get('https://www.example.com/');
print $response->content, "\n";
## Description
-this 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 for more information on POST requests.
+This 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.
-The "Crypt::SSLeay" package provides "Net::SSL", which is loaded by
-"LWP::Protocol::https" for https requests and provides the necessary SSL
-glue.
+The `Crypt::SSLeay` package provides `Net::SSL`, which is loaded by `LWP::Protocol::https` for https requests and provides the necessary SSL glue.
This distribution also makes following deprecated modules available:
Crypt::SSLeay::Conn
Crypt::SSLeay::X509
-Work on Crypt::SSLeay has been continued only to provide https support
-for the LWP (libwww-perl) libraries.
+Work on Crypt::SSLeay has been continued only to provide https support for the LWP (libwww-perl) libraries.
## Environment Variables
-the following environment variables change the way "Crypt::SSLeay" and
-"Net::SSL" behave.
+The following environment variables change the way `Crypt::SSLeay` and `Net::SSL` behave.
+
+### Specify SSL Socket Class
+
+ $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}
+
+can be used to instruct `LWP::UserAgent` to use `Net::SSL` for HTTPS support rather than `IO::Socket::SSL`.
### Proxy Support
$ENV{HTTPS_CA_DIR} = 'certs/';
### Client PKCS12 cert support
+
$ENV{HTTPS_PKCS12_FILE} = 'certs/pkcs12.pkcs12';
$ENV{HTTPS_PKCS12_PASSWORD} = 'PKCS12_PASSWORD';
### OpenSSL
-You must have OpenSSL installed before compiling this module. You can
-get the latest OpenSSL package from <http://www.openssl.org/>. We no longer
-support pre-2000 versions of OpenSSL.
+You 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.
+
+If you are building OpenSSL from source, please follow the directions included in the source package.
+
+### Crypt::SSLeay via Makefile.PL
+
+`Makefile.PL` accepts the following command line arguments:
+
+
+#### incpath
+
+Path 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.
-If you are building OpenSSL from source, please follow the directions
-included in the package.
+#### libpath
-If you are going to use an OpenSSL library which you built from source or
-whose header and library files are not in a place searched by your compiler
-by default, make sure you set appropriate environment variables before
-trying to build `Crypt::SSLeay`.
+Path 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.
-For example, if you are using ActiveState Perl and MinGW installed using
-ppm, and you installed OpenSSL in `C:\opt\openssl-1.0.1c`, then you would
-issue the following commands to build `Crypt::SSLeay`:
+#### live-tests
- C:\temp\Crypt-SSLeay> set LIBRARY_PATH=C:\opt\openssl-1.0.1c\lib;%LIBRARY_PATH%
- C:\temp\Crypt-SSLeay> set CPATH=C:\opt\openssl-1.0.1c\include;%CPATH%
- C:\temp\Crypt-SSLeay> perl Makefile.PL --live-tests
- C:\temp\Crypt-SSLeay> dmake test
+Use `--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.
-On Linux/BSD/Solaris/GNU etc systems, you would use `make` rather than
-`dmake`, but you would need to set the same variables if your OpenSSL
-library is in a custom location. If everything builds OK, but you get
-failures when during tests, ensure that `LD_LIBRARY_PATH` points to the
-location where the correct shared libraries are located.
+Default is false.
-If you are using a Microsoft compiler (keep in mind that `perl` and OpenSSL
-need to have been built using the same compiler as well), you would use:
- C:\temp\Crypt-SSLeay> set LIB=C:\opt\openssl-1.0.1c\lib;%LIB%
- C:\temp\Crypt-SSLeay> set INCLUDE=C:\opt\openssl-1.0.1c\include;%INCLUDE%
- C:\temp\Crypt-SSLeay> perl Makefile.PL --live-tests
- C:\temp\Crypt-SSLeay> nmake test
+#### static
-Depending on your OS, pre-built OpenSSL packages may be available. You may
-need to install a development version of your operating system's OpenSSL
-library package. The key is that Crypt::SSLeay makes calls to the OpenSSL
-library, and how to do so is specified in the C header files that come
-with the library. Some systems break out the header files into a separate
-package from that of the libraries. Once the program has been built, you
-don't need the headers any more.
+Boolean. Default is false. TODO: How is this even supposed to work?
-### `Crypt::SSLeay`
+#### verbose
-The latest `Crypt::SSLeay` can be found at your nearest CPAN, as well as
-<http://search.cpan.org/dist/Crypt-SSLeay/>.
+Boolean. 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.
-Once you have downloaded it, `Crypt::SSLeay` installs easily using the
-standard build process:
+If 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.
+
+### Crypt::SSLeay
+
+The latest `Crypt::SSLeay` can be found at your nearest CPAN, as well as on [metacpan](https://metacpan.org/dist/Crypt::SSLeay).
+
+Once you have downloaded and extracted it, `Crypt::SSLeay` installs easily using the standard build process:
perl Makefile.PL
make
make test
make install
-On Windows systems, both Strawberry Perl and ActiveState (as a separate
-download via ppm) projects include a MingW based compiler distribution and
-dmake which can be used to build both OpenSSL and `Crypt::SSLeay`. If you have
-such a set up, use dmake above.
-
-Makefile.PL takes two optional arguments:
+Alternatively, you can use [cpanm](https://metacpan.org/pod/App::cpanminus):
-* `--live-tests` : Boolean. Specifies whether we should try to connect to
- an HTTPS URL during testing. Default is false.
+ cpanm Crypt::SSLeay
- To skip live tests, you can use
+If you have OpenSSL headers and libraries in nonstandard locations, you can use
- perl Makefile.PL --no-live-tests
+ $ perl Makefile.PL --incpath=... --libpath=...
- and to force live tests, you can use
+If you would like to use "cpanm" with such custom locations, you can do
- perl Makefile.PL --live-tests
+ $ OPENSSL_INCLUDE=... OPENSSL_LIB=... cpanm Crypt::SSLeay
-* `--static` : Boolean. Default is false. (TODO: Does it work?)
+or, on Windows,
-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`.
+ > set OPENSSL_INCLUDE=...
+ > set OPENSSL_LIB=...
+ > cpanm Crypt::SSLeay
-### Windows
+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`.
-`Crypt::SSLeay` builds correctly with Strawberry Perl and ActiveState Perl
-using the bundled MinGW.
+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`.
-For ActiveState Perl users, the ActiveState company does not have a
-permit from the Canadian Federal Government to distribute cryptographic
-software. This prevents `Crypt::SSLeay` from being distributed as a PPM
-package from their repository. See <http://docs.activestate.com/activeperl/5.16/faq/ActivePerl-faq2.html#crypto_packages>
-for more information on this issue. You may be able to download a PPM for
-`Crypt::SSLeay` from an alternative repository (see `PPM::Repositories`).
+#### VMS
-### 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 ticket on RT with the information so I can add it to
-this document.
+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 ticket on RT with the information so I can add it to this document.
## 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` 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:
+`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:
+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.
+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:
+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.
+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:
+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.
+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:
+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:
+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.
+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.
+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>.
+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?)
+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:
+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 \
$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"?)
+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:
+`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 v2 : old connection type
-Unfortunately, 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`:
+Unfortunately, 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`:
$ENV{HTTPS_VERSION} = 3;
-to 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.
+to 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.
## Acknowledgements
many thanks to the following individuals who helped improve Crypt-SSLeay:
-* _Gisle Aas_ for writing this module and many others including libwww,
-for perl. The web will never be the same :)
+* _Gisle Aas_ for writing this module and many others including libwww, for Perl. The web will never be the same :)
-* _Ben Laurie_ deserves kudos for his excellent patches for better error
-handling, SSL information inspection, and random seeding.
+* _Ben Laurie_ deserves kudos for his excellent patches for better error handling, SSL information inspection, and random seeding.
* _Dongqiang Bai_ for host name resolution fix when using a proxy.
-* _Stuart Horner_ of Core Communications, Inc. who found the need for
-building `--shared` OpenSSL libraries.
+* _Stuart Horner_ of Core Communications, Inc. who found the need for building `--shared` OpenSSL libraries.
-* _Pavel Hlavnicka_ for a patch for freeing memory when using a pkcs12
-file, and for inspiring more robust `read()` behavior.
+* _Pavel Hlavnicka_ for a patch for freeing memory when using a pkcs12 file, and for inspiring more robust `read()` behavior.
-* _James Woodyatt_ is a champ for finding a ridiculous memory leak that
-has been the bane of many a `Crypt::SSLeay` user.
+* _James Woodyatt_ is a champ for finding a ridiculous memory leak that has been the bane of many a `Crypt::SSLeay` user.
-* _Bryan Hart_ for his patch adding proxy support, and thanks to _Tobias
-Manthey_ for submitting another approach.
+* _Bryan Hart_ for his patch adding proxy support, and thanks to _Tobias Manthey_ for submitting another approach.
* _Alex Rhomberg_ for Alpha linux ccc patch.
* _Jeff Lavallee_ for help with alarms on read failures (CPAN bug #12444).
-* _Guenter Knauf_ for significant improvements in configuring things in
-Win32 and Netware lands and Jan Dubois for various suggestions for
-improvements.
+* _Guenter Knauf_ for significant improvements in configuring things in Win32 and Netware lands and Jan Dubois for various suggestions for improvements.
+
+and _many others_ who provided bug reports, suggestions, fixes and patches.
-and _many others_ who provided bug reports, suggestions, fixes and
-patches.
+If 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).
### TODO: Update acknowledgements list.
* `Net::SSLeay`
- Net::SSLeay provides access to the OpenSSL API directly from Perl.
- See <http://search.cpan.org/dist/Net-SSLeay/>.
+ [Net::SSLeay](https://metacpan.org/pod/Net::SSLeay) provides access to the OpenSSL API directly from Perl.
+
+* [OpenSSL binary packages for Windows](http://www.openssl.org/related/binaries.html)
+
+* [IO::Socket::SSL](https://metacpan.org/pod/IO::Socket::SSL)
-* OpenSSL binary packages for Windows, see
- <http://www.openssl.org/related/binaries.html>.
+* [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).
## Support
-* For use of `Crypt::SSLeay` & `Net::SSL` with Perl's LWP, please send email
- to libwww@perl.org <mailto:libwww@perl.org>.
+* For use of `Crypt::SSLeay` & `Net::SSL` with Perl's LWP, please send email to [libwww@perl.org](mailto:libwww@perl.org).
-* 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.
+* 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.
-* Please report all bugs at
- <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Crypt-SSLeay>.
+* Please report all bugs on [rt.cpan.org](http://rt.cpan.org/NoAuth/Bugs.html?Dist=Crypt-SSLeay).
## Authors
-This module was originally written by Gisle Aas, and was subsequently
-maintained by Joshua Chamas, David Landgren, brian d foy, and A. Sinan
-Unur.
+This module was originally written by Gisle Aas, and was subsequently maintained by Joshua Chamas, David Landgren, brian d foy, and A. Sinan Unur.
## Copyright
-Copyright © 2010-2012 A. Sinan Unur
+Copyright © 2010-2014 A. Sinan Unur
Copyright © 2006-2007 David Landgren
## License
-this program is free software; you can redistribute it and/or modify it
-under the terms of Artistic License 2.0. See <http://www.perlfoundation.org/artistic_license_2_0>.
+This 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).
use strict;
use vars '$VERSION';
-$VERSION = '0.64';
+$VERSION = '0.72';
+$VERSION = eval $VERSION;
eval {
require XSLoader;
use Crypt::SSLeay::X509;
-# A xsupp bug made this nessesary
+# A xsupp bug made this necessary
sub Crypt::SSLeay::CTX::DESTROY { shift->free; }
sub Crypt::SSLeay::Conn::DESTROY { shift->free; }
sub Crypt::SSLeay::X509::DESTROY { shift->free; }
Crypt::SSLeay - OpenSSL support for LWP
-=head1 SYNOPSIS
+=head1 HEARTBLEED WARNING
+
+C<perl Makefile.PL> will display a warning if it thinks your OpenSSL might be vulnerable to the L<Heartbleed Bug|https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160>. You can, of course, go ahead and install the module, but you should be aware that your system might be exposed to an extremely serious vulnerability. This is just a heuristic based on the version reported by OpenSSL. It is entirely possible that your distrbution actually pushed a patched library, so if you have concerns, you should investigate further.
- lwp-request https://www.example.com
+=head1 SYNOPSIS
+ use Net::SSL;
use LWP::UserAgent;
- my $ua = LWP::UserAgent->new;
+
+ my $ua = LWP::UserAgent->new(
+ ssl_opts => { verify_hostname => 0 },
+ );
+
my $response = $ua->get('https://www.example.com/');
print $response->content, "\n";
=head1 DESCRIPTION
-This Perl module provides support for the HTTPS protocol under LWP,
-to allow an C<LWP::UserAgent> object to perform GET, HEAD and POST
-requests. Please see LWP for more information on POST requests.
+This Perl module provides support for the HTTPS protocol under L<LWP>, to
+allow an L<LWP::UserAgent> object to perform GET, HEAD, and POST requests
+over encrypted socket connections. Please see L<LWP> for more information
+on POST requests.
-The C<Crypt::SSLeay> package provides C<Net::SSL>, which is loaded
-by C<LWP::Protocol::https> for https requests and provides the
+The C<Crypt::SSLeay> package provides C<Net::SSL>, which, if requested, is
+loaded by C<LWP::Protocol::https> for https requests and provides the
necessary SSL glue.
This distribution also makes following deprecated modules available:
Crypt::SSLeay::Conn
Crypt::SSLeay::X509
-Work on Crypt::SSLeay has been continued only to provide https
-support for the LWP (libwww-perl) libraries.
+=head1 DO YOU NEED Crypt::SSLeay?
+
+Starting with version 6.02 of L<LWP>, C<https> support was unbundled into
+L<LWP::Protocol::https>. This module specifies as one of its prerequisites
+L<IO::Socket::SSL> which is automatically used by L<LWP::UserAgent> unless
+this preference is overridden separately. C<IO::Socket::SSL> is a more
+complete implementation, and, crucially, it allows hostname verification.
+C<Crypt::SSLeay> does not support this. At this point, C<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
+C<Crypt::SSLeay>, only on the ability of C<LWP::UserAgent> class to
+communicate with sites over SSL/TLS.
+
+If are using version C<LWP> 6.02 or later, and therefore have installed
+C<LWP::Protocol::https> and its dependencies, and do not explicitly C<use>
+C<Net::SSL> before loading C<LWP::UserAgent>, or override the default socket
+class, you are probably using C<IO::Socket::SSL> and do not really need
+C<Crypt::SSLeay>.
+
+If you have both C<Crypt::SSLeay> and C<IO::Socket::SSL> installed, and
+would like to force C<LWP::UserAgent> to use C<Crypt::SSLeay>, you can
+use:
+
+ use Net::HTTPS;
+ $Net::HTTPS::SSL_SOCKET_CLASS = 'Net::SSL';
+ use LWP::UserAgent;
+
+or
+
+ local $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = 'Net::SSL';
+ use LWP::UserAgent;
+
+or
+
+ use Net::SSL;
+ use LWP::UserAgent;
=head1 ENVIRONMENT VARIABLES
-The following environment variables change the way
-C<Crypt::SSLeay> and C<Net::SSL> behave.
+=over 4
+
+=item Specify SSL Socket Class
+
+C<$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS}> can be used to instruct
+C<LWP::UserAgent> to use C<Net::SSL> for HTTPS support rather than
+C<IO::Socket::SSL>.
-=head2 Proxy Support
+=item Proxy Support
$ENV{HTTPS_PROXY} = 'http://proxy_hostname_or_ip:port';
-=head2 Proxy Basic Authentication
+=item Proxy Basic Authentication
$ENV{HTTPS_PROXY_USERNAME} = 'username';
$ENV{HTTPS_PROXY_PASSWORD} = 'password';
-=head2 SSL diagnostics and Debugging
+=item SSL diagnostics and Debugging
$ENV{HTTPS_DEBUG} = 1;
-=head2 Default SSL Version
+=item Default SSL Version
$ENV{HTTPS_VERSION} = '3';
-=head2 Client Certificate Support
+=item Client Certificate Support
$ENV{HTTPS_CERT_FILE} = 'certs/notacacert.pem';
$ENV{HTTPS_KEY_FILE} = 'certs/notacakeynopass.pem';
-=head2 CA cert Peer Verification
+=item CA cert Peer Verification
$ENV{HTTPS_CA_FILE} = 'certs/ca-bundle.crt';
$ENV{HTTPS_CA_DIR} = 'certs/';
-=head2 Client PKCS12 cert support
+=item Client PKCS12 cert support
$ENV{HTTPS_PKCS12_FILE} = 'certs/pkcs12.pkcs12';
$ENV{HTTPS_PKCS12_PASSWORD} = 'PKCS12_PASSWORD';
+=back
+
=head1 INSTALL
=head2 OpenSSL
You must have OpenSSL installed before compiling this module. You can get
-the latest OpenSSL package from L<http://www.openssl.org/>. We no longer
-support pre-2000 versions of OpenSSL.
+the latest OpenSSL package from L<https://www.openssl.org/source/>. We no
+longer support pre-2000 versions of OpenSSL.
If you are building OpenSSL from source, please follow the directions
-included in the package.
-
-If you are going to use an OpenSSL library which you built from source or
-whose header and library files are not in a place searched by your compiler
-by default, make sure you set appropriate environment variables before
-trying to build C<Crypt::SSLeay>.
-
-For example, if you are using ActiveState Perl and MinGW installed using
-ppm, and you installed OpenSSL in C<C:\opt\openssl-1.0.1c>, then you would
-issue the following commands to build C<Crypt::SSLeay>:
-
- C:\...\> set LIBRARY_PATH=C:\opt\openssl-1.0.1c\lib;%LIBRARY_PATH%
- C:\...\> set CPATH=C:\opt\openssl-1.0.1c\include;%CPATH%
- C:\...\> perl Makefile.PL --live-tests
- C:\...\> dmake test
-
-On Linux/BSD/Solaris/GNU etc systems, you would use make rather than dmake,
-but you would need to set the same variables if your OpenSSL library is in a
-custom location. If everything builds OK, but you get failures when during
-tests, ensure that C<LD_LIBRARY_PATH> points to the location where the
-correct shared libraries are located.
-
-If you are using a Microsoft compiler (keep in mind that perl and OpenSSL
-need to have been built using the same compiler as well), you would use:
-
- C:\...\> set LIB=C:\opt\openssl-1.0.1c\lib;%LIB%
- C:\...\> set INCLUDE=C:\opt\openssl-1.0.1c\include;%INCLUDE%
- C:\...\> perl Makefile.PL --live-tests
- C:\...\> nmake test
-
-Depending on your OS, pre-built OpenSSL packages may be available. You may
-need to install a development version of your operating system's OpenSSL
-library package. The key is that C<Crypt::SSLeay> makes calls to the OpenSSL
-library, and how to do so is specified in the C header files that come
-with the library. Some systems break out the header files into a separate
-package from that of the libraries. Once the program has been built, you
-don't need the headers any more.
+included in the source package.
-=head2 Crypt::SSLeay
+=head2 Crypt::SSLeay via Makefile.PL
-The latest Crypt::SSLeay can be found at your nearest CPAN, as well as
-L<http://search.cpan.org/dist/Crypt-SSLeay/>.
+C<Makefile.PL> accepts the following command line arguments:
-Once you have downloaded it, C<Crypt::SSLeay> installs easily using the
-standard build process:
-
- perl Makefile.PL
- make
- make test
- make install
+=over 4
-On Windows systems, both Strawberry Perl and ActiveState (as a separate
-download via ppm) projects include a MingW based compiler distribution and
-dmake which can be used to build both OpenSSL and C<Crypt::SSLeay>. If you
-have such a set up, use dmake above.
+=item C<incpath>
-F<Makefile.PL> takes two optional arguments:
+Path to OpenSSL headers. Can also be specified via C<$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 C<CPATH> or C<INCLUDE> etc.
-=over 4
+=item C<libpath>
-=item C<--live-tests>
+Path to OpenSSL libraries. Can also be specified via C<$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 C<LIBRARY_PATH> or C<LIB> etc.
-Boolean. Specifies whether we should try to connect to an HTTPS URL during
-testing. Default is false.
+=item C<live-tests>
-To skip live tests, you can use
+Use C<--live-tests> to request tests that try to connect to an external web
+site, and C<--no-live_tests> to prevent such tests from running. If you run
+C<Makefile.PL> interactively, and this argument is not specified on the
+command line, you will be prompted for a value.
- perl Makefile.PL --no-live-tests
+Default is false.
-and to force live tests, you can use
+=item C<static>
- perl Makefile.PL --live-tests
+Boolean. Default is false. B<TODO>: Does it work?
-=item C<--static>
+=item C<verbose>
-Boolean. Default is false. (B<TODO>: Does it work?)
+Boolean. Default is false. If you pass C<--verbose> on the command line,
+both C<Devel::CheckLib> and C<ExtUtils::CBuilder> instances will be
+configured to echo what they are doing.
=back
-For unattended (batch) installations, to be absolutely certain that
-F<Makefile.PL> does not prompt for questions on STDIN, set the environment
-variable C<PERL_MM_USE_DEFAULT=1> as with any CPAN module built using
-L<ExtUtils::MakeMaker>.
+If everything builds OK, but you get failures when during tests, ensure that
+C<LD_LIBRARY_PATH> points to the location where the correct shared libraries
+are located.
+
+If you are using a custom OpenSSL build, please keep in mind that
+C<Crypt::SSLeay> must be built using the same compiler and build tools used
+to build C<perl> and OpenSSL. This can be more of an issue on Windows. If
+you are using Active State Perl, install the MinGW package distributed by
+them, and build OpenSSL using that before trying to build this module. If
+you have built your own Perl using Microsoft SDK tools or IDEs, make sure
+you build OpenSSL using the same tools.
+
+Depending on your OS, pre-built OpenSSL packages may be available. To get
+the require headers and import libraries, you may need to install a
+development version of your operating system's OpenSSL library package. The
+key is that C<Crypt::SSLeay> makes calls to the OpenSSL library, and how to
+do so is specified in the C header files that come with the library. Some
+systems break out the header files into a separate package from that of the
+libraries. Once the program has been built, you don't need the headers any
+more.
+
+=head2 Crypt::SSLeay
+
+The latest Crypt::SSLeay can be found at your nearest CPAN mirror, as well
+as L<https://metacpan.org/pod/Crypt::SSLeay>.
+
+Once you have downloaded it, C<Crypt::SSLeay> installs easily using the
+standard build process:
+
+ $ perl Makefile.PL
+ $ make
+ $ make test
+ $ make install
+
+or
-=head3 Windows
+ $ cpanm Crypt::SSLeay
-C<Crypt::SSLeay> builds correctly with Strawberry Perl and ActiveState Perl
-using the bundled MinGW.
+If you have OpenSSL headers and libraries in nonstandard locations, you can
+use
-For ActiveState Perl users, the ActiveState company does not have a permit
-from the Canadian Federal Government to distribute cryptographic software.
-This prevents C<Crypt::SSLeay> from being distributed as a PPM package from
-their repository.
+ $ perl Makefile.PL --incpath=... --libpath=...
-See L<http://docs.activestate.com/activeperl/5.16/faq/ActivePerl-faq2.html#crypto_packages>
-for more information on this issue. You may be able to download a PPM for
-C<Crypt::SSLeay> from an alternative repository (see L<PPM::Repositories>).
+If you would like to use C<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 C<dmake> rather than
+C<make>. If you are using Microsoft's build tools, you would use C<nmake>.
+
+For unattended (batch) installations, to be absolutely certain that
+F<Makefile.PL> does not prompt for questions on STDIN, set the environment
+variable C<PERL_MM_USE_DEFAULT=1> as with any CPAN module built using
+L<ExtUtils::MakeMaker>.
=head3 VMS
=head1 SSL versions
C<Crypt::SSLeay> tries very hard to connect to I<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:
+accommodating servers that are buggy, old or simply not standards-compliant.
+To this effect, this module will try SSL connections in this order:
=over 4
$ENV{HTTPS_VERSION} = 3;
-to 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.
+to 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.
=head1 ACKNOWLEDGEMENTS
and I<many others> who provided bug reports, suggestions, fixes and
patches.
+If you have reported a bug or provided feedback, and you would like to be
+mentioned by name in this section, please file request on
+L<rt.cpan.org|http://rt.cpan.org/NoAuth/Bugs.html?Dist=Crypt-SSLeay>.
+
=head1 SEE ALSO
=over 4
=item Net::SSLeay
L<Net::SSLeay> provides access to the OpenSSL API directly
-from Perl. See L<http://search.cpan.org/dist/Net-SSLeay/>.
+from Perl. See L<https://metacpan.org/pod/Net::SSLeay/>.
-=item OpenSSL binary packages for Windows
+=item Building OpenSSL on 64-bit Windows 8.1 Pro using SDK tools
-See L<http://www.openssl.org/related/binaries.html>.
+My blog post L<http://blog.nu42.com/2014/04/building-openssl-101g-on-64-bit-windows.html> might be helpful.
=back
=head1 SUPPORT
-For use of C<Crypt::SSLeay> & C<Net::SSL> with Perl's L<LWP>, please
-send email to C<libwww@perl.org>.
+For issues related to using of C<Crypt::SSLeay> & C<Net::SSL> with Perl's
+L<LWP>, please send email to C<libwww@perl.org>.
For OpenSSL or general SSL support, including issues associated with
building and installing OpenSSL on your system, please email the OpenSSL
=head1 COPYRIGHT
-Copyright (c) 2010-2012 A. Sinan Unur
+Copyright (c) 2010-2014 A. Sinan Unur
Copyright (c) 2006-2007 David Landgren
MODULE = Crypt::SSLeay PACKAGE = Crypt::SSLeay::Err PREFIX = ERR_
-char*
+#define CRYPT_SSLEAY_ERR_BUFSIZE 1024
+
+const char *
ERR_get_error_string()
- CODE:
- unsigned long l;
- char buf[1024];
-
- if(!(l=ERR_get_error()))
- RETVAL=NULL;
- else {
- ERR_error_string(l,buf);
- RETVAL=buf;
- }
- OUTPUT:
- RETVAL
+ PREINIT:
+ unsigned long code;
+ char buf[ CRYPT_SSLEAY_ERR_BUFSIZE ];
+
+ CODE:
+ if ((code = ERR_get_error()) == 0) {
+ RETVAL = NULL;
+ }
+ else {
+ /* www.openssl.org/docs/crypto/ERR_error_string.html */
+ ERR_error_string_n(code, buf, CRYPT_SSLEAY_ERR_BUFSIZE);
+ RETVAL = buf;
+ }
+ OUTPUT:
+ RETVAL
MODULE = Crypt::SSLeay PACKAGE = Crypt::SSLeay::CTX PREFIX = SSL_CTX_
+#define CRYPT_SSLEAY_RAND_BUFSIZE 1024
+
SSL_CTX*
SSL_CTX_new(packname, ssl_version)
SV* packname
CODE:
SSL_CTX* ctx;
static int bNotFirstTime;
- char buf[1024];
- int rand_bytes_read;
+ char buf[ CRYPT_SSLEAY_RAND_BUFSIZE ];
if(!bNotFirstTime) {
- SSLeay_add_all_algorithms();
+ OpenSSL_add_all_algorithms();
SSL_load_error_strings();
ERR_load_crypto_strings();
SSL_library_init();
/**** Code from Devin Heitmueller, 10/3/2002 ****/
/**** Use /dev/urandom to seed if available ****/
- rand_bytes_read = RAND_load_file("/dev/urandom", 1024);
- if (rand_bytes_read <= 0) {
+ /* ASU: 2014/04/23 It looks like it is OK to leave
+ * this in. See following thread:
+ * http://security.stackexchange.com/questions/56469/
+ */
+ if (RAND_load_file("/dev/urandom", CRYPT_SSLEAY_RAND_BUFSIZE)
+ != CRYPT_SSLEAY_RAND_BUFSIZE)
+ {
/* Couldn't read /dev/urandom, just seed off
* of the stack variable (the old way)
*/
- RAND_seed(buf,sizeof buf);
+ RAND_seed(buf, CRYPT_SSLEAY_RAND_BUFSIZE);
}
if(ssl_version == 23) {
ctx = SSL_CTX_new(SSLv3_client_method());
}
else {
-#ifndef OPENSSL_NO_SSL2
- /* v2 is the default */
+#ifndef OPENSSL_NO_SSL2
+ /* v2 is the default */
ctx = SSL_CTX_new(SSLv2_client_method());
-#else
+#else
/* v3 is the default */
ctx = SSL_CTX_new(SSLv3_client_method());
#endif
- }
+ }
SSL_CTX_set_options(ctx,SSL_OP_ALL|0);
SSL_CTX_set_default_verify_paths(ctx);
int
SSL_CTX_use_pkcs12_file(ctx, filename, password)
SSL_CTX* ctx
- char* filename
- char* password
+ const char *filename
+ const char *password
PREINIT:
FILE *fp;
EVP_PKEY *pkey;
p12 = d2i_PKCS12_fp(fp, NULL);
fclose (fp);
- if (p12) {
+ if (p12) {
if(PKCS12_parse(p12, password, &pkey, &cert, &ca)) {
if (pkey) {
RETVAL = SSL_CTX_use_PrivateKey(ctx, pkey);
ssl = SSL_new(ctx);
SSL_set_connect_state(ssl);
/* The set mode is necessary so the SSL connection can
- * survive a renegotiated cipher that results from
- * modssl VerifyClient config changing between
+ * survive a renegotiated cipher that results from
+ * modssl VerifyClient config changing between
* VirtualHost & some other config block. At modssl
* this would be a [trace] ssl message:
* "Changed client verification type will force renegotiation"
* -- jc 6/28/2001
- */
+ */
#ifdef SSL_MODE_AUTO_RETRY
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
#endif
SSL_free(ssl)
SSL* ssl
+int
+SSL_pending(ssl)
+ SSL* ssl
+
int
SSL_set_fd(ssl,fd)
SSL* ssl
{
int n = SSL_write(ssl, buf+offset, len);
int x = SSL_get_error(ssl, n);
-
+
if ( n >= 0 )
{
keep_trying_to_write = 0;
}
else
{
- if
+ if
(
(x != SSL_ERROR_WANT_READ) &&
(x != SSL_ERROR_WANT_WRITE)
}
if (len < 0)
croak("Negative length");
-
+
SvGROW(sv, offset + len + 1);
buf = SvPVX(sv); /* it might have been relocated */
else
{
if
- (
- (x != SSL_ERROR_WANT_READ) &&
- (x != SSL_ERROR_WANT_WRITE)
- )
+ (
+ (x != SSL_ERROR_WANT_READ) &&
+ (x != SSL_ERROR_WANT_WRITE)
+ )
{
keep_trying_to_read = 0;
RETVAL = &PL_sv_undef;
OUTPUT:
RETVAL
+#define CRYPT_SSLEAY_SHARED_CIPHERS_BUFSIZE 512
+
char*
SSL_get_shared_ciphers(ssl)
- SSL* ssl
- PREINIT:
- char buf[512];
- CODE:
- RETVAL = SSL_get_shared_ciphers(ssl, buf, sizeof(buf));
- OUTPUT:
- RETVAL
+ SSL* ssl
+ PREINIT:
+ char buf[ CRYPT_SSLEAY_SHARED_CIPHERS_BUFSIZE ];
+ CODE:
+ RETVAL = SSL_get_shared_ciphers(
+ ssl, buf, CRYPT_SSLEAY_SHARED_CIPHERS_BUFSIZE
+ );
+ OUTPUT:
+ RETVAL
char*
SSL_get_cipher(ssl)
CODE:
RETVAL = (char*) SSL_get_cipher(ssl);
OUTPUT:
- RETVAL
+ RETVAL
#if OPENSSL_VERSION_NUMBER >= 0x0090806fL && !defined(OPENSSL_NO_TLSEXT)
OUTPUT:
RETVAL
+MODULE = Crypt::SSLeay PACKAGE = Crypt::SSLeay::Version PREFIX = VERSION_
+
+const char *
+VERSION_openssl_version()
+ CODE:
+ RETVAL = SSLeay_version(SSLEAY_VERSION);
+ OUTPUT:
+ RETVAL
+
+long
+VERSION_openssl_version_number()
+ CODE:
+ RETVAL = OPENSSL_VERSION_NUMBER;
+ OUTPUT:
+ RETVAL
+
+const char *
+VERSION_openssl_cflags()
+ CODE:
+ RETVAL = SSLeay_version(SSLEAY_CFLAGS);
+ OUTPUT:
+ RETVAL
+
+const char *
+VERSION_openssl_platform()
+ CODE:
+ RETVAL = SSLeay_version(SSLEAY_PLATFORM);
+ OUTPUT:
+ RETVAL
+
+const char *
+VERSION_openssl_built_on()
+ CODE:
+ RETVAL = SSLeay_version(SSLEAY_BUILT_ON);
+ OUTPUT:
+ RETVAL
+
+const char *
+VERSION_openssl_dir()
+ CODE:
+ RETVAL = SSLeay_version(SSLEAY_DIR);
+ OUTPUT:
+ RETVAL
+
--- /dev/null
+package IO::Interactive::Tiny;
+
+# use strict;
+# use warnings;
+
+$IO::Interactive::Tiny::VERSION = '0.2';
+
+sub is_interactive {
+ my ($out_handle) = (@_, select); # Default to default output handle
+
+ # Not interactive if output is not to terminal...
+ return 0 if not -t $out_handle;
+
+ # If *ARGV is opened, we're interactive if...
+ if ( tied(*ARGV) or defined(fileno(ARGV)) ) { # IO::Interactive::Tiny: this is the only relavent part of Scalar::Util::openhandle() for 'openhandle *ARGV'
+ # ...it's currently opened to the magic '-' file
+ return -t *STDIN if defined $ARGV && $ARGV eq '-';
+
+ # ...it's at end-of-file and the next file is the magic '-' file
+ return @ARGV>0 && $ARGV[0] eq '-' && -t *STDIN if eof *ARGV;
+
+ # ...it's directly attached to the terminal
+ return -t *ARGV;
+ }
+
+ # If *ARGV isn't opened, it will be interactive if *STDIN is attached
+ # to a terminal.
+ else {
+ return -t *STDIN;
+ }
+}
+
+1;
--- /dev/null
+package Crypt::SSLeay::Version;
+require Crypt::SSLeay;
+
+use Exporter qw( import );
+
+our @EXPORT = qw();
+
+our @EXPORT_OK = qw(
+ openssl_built_on
+ openssl_cflags
+ openssl_dir
+ openssl_platform
+ openssl_version
+ openssl_version_number
+);
+
+use strict;
+__PACKAGE__;
+__END__
+
+=head1 NAME
+
+Crypt::SSLeay::Version - Obtain OpenSSL version information
+
+=head1 SYNOPSIS
+
+ use Crypt::SSLeay::Version qw(\
+ openssl_built_on
+ openssl_cflags
+ openssl_dir
+ openssl_platform
+ openssl_version
+ openssl_version_number
+ );
+
+ my $version = openssl_version();
+
+ if (openssl_cflags() =~ /DOPENSSL_NO_HEARTBEATS/) {
+ print "OpenSSL was compiled without heartbeats\n";
+ }
+
+=head1 SUMMARY
+
+Exposes information provided by L<SSLeay_version|https://www.openssl.org/docs/crypto/SSLeay_version.html>.
+
+=head1 EXPORTS
+
+By default, the module exports nothing. You can ask for each subroutine bloew to be exported to your namespace.
+
+=head1 SUBROUTINES
+
+=head2 openssl_built_on
+
+The date of the build process in the form "built on: ..." if available or ``built on: date not available'' otherwise.
+
+=head2 openssl_cflags
+
+The compiler flags set for the compilation process in the form "compiler: ..." if available or "compiler: information not available" otherwise.
+
+=head2 openssl_dir
+
+The C<OPENSSLDIR> setting of the library build in the form "OPENSSLDIR: ..." if available or "OPENSSLDIR: N/A" otherwise.
+
+=head2 openssl_platform
+
+The "Configure" target of the library build in the form "platform: ..." if available or "platform: information not available" otherwise.
+
+=head2 openssl_version
+
+The version of the OpenSSL library including the release date.
+
+=head2 openssl_version_number
+
+The value of the C<OPENSSL_VERSION_NUMBER> macro as an unsigned integer. This value is more like a string as version information is packed into specific nibbles see C<crypto/opensslv.h> in the OpenSSL source and L<https://metacpan.org/pod/OpenSSL::Versions|OpenSSL::Versions> for explanation.
+
+=head1 AUTHOR
+
+A. Sinan Unur C<< <nanis@cpan.org> >>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2014 A. Sinan Unur.
+
+=head1 LICENSE
+
+This program is free software; you can redistribute it and/or modify it under the terms of L<Artistic License 2.0|http://www.perlfoundation.org/artistic_license_2_0>.
+
use Carp;
use vars qw(@ISA $VERSION $NEW_ARGS);
-$VERSION = '2.85';
+$VERSION = '2.86';
+$VERSION = eval $VERSION;
require IO::Socket;
@ISA=qw(IO::Socket::INET);
*$self->{ssl_ssl}->get_cipher(@_);
}
+sub pending {
+ my $self = shift;
+ $self = $REAL{$self} || $self;
+ *$self->{ssl_ssl}->pending(@_);
+}
+
sub ssl_context {
my $self = shift;
$self = $REAL{$self} || $self;
# better) may actually make this problem go away, but either way,
# there is no good reason to use \d when checking for 0-9
- while ($header !~ m{HTTP/[0-9][.][0-9]\s+200\s+.*$CRLF$CRLF}) {
+ while ($header !~ m{HTTP/[0-9][.][0-9]\s+200\s+.*$CRLF$CRLF}s) {
$timeout = $self->timeout(5) unless length $header;
my $n = $self->SUPER::sysread($header, 8192, length $header);
last if $n <= 0;
}
$proxy_server =~ s|\Ahttps?://||i;
+ # sanitize the end of the string too
+ # see also http://www.nntp.perl.org/group/perl.libwww/2012/10/msg7629.html
+ # and https://github.com/nanis/Crypt-SSLeay/pull/1
+ # Thank you Mark Allen and YigangX Wen
+ $proxy_server =~ s|(:[1-9][0-9]{0,4})/\z|$1|;
$proxy_server;
}
C<undef> if nothing was read, otherwise returns the data as
a scalar.
+=item pending
+
+Provides access to OpenSSL's C<pending> attribute on the SSL connection
+object.
+
=item getline
Reads one character at a time until a newline is encountered,
--- /dev/null
+#include <stdio.h>
+#include <openssl/opensslv.h>
+
+int main(void) {
+ puts(OPENSSL_VERSION_TEXT);
+ printf("%8lx\n", OPENSSL_VERSION_NUMBER);
+ return 0;
+}
# 00-basic.t
-use Test::More tests => 12;
+use Test::More;
BEGIN {
use_ok( 'Crypt::SSLeay' );
use_ok( 'Crypt::SSLeay::Err' );
use_ok( 'Crypt::SSLeay::MainContext', 'main_ctx' );
use_ok( 'Crypt::SSLeay::X509' );
+ use_ok(
+ 'Crypt::SSLeay::Version',
+ qw(
+ openssl_built_on
+ openssl_cflags
+ openssl_dir
+ openssl_platform
+ openssl_version
+ openssl_version_number
+ ),
+ );
use_ok( 'Net::SSL' );
}
}
SKIP: {
- skip( 'Test::Pod::Coverage not installed on this system', 2 )
- unless do {
- eval "use Test::Pod::Coverage";
- $@ ? 0 : 1;
- };
- pod_coverage_ok( 'Crypt::SSLeay', 'Crypt-SSLeay POD coverage is go!' );
- pod_coverage_ok( 'Net::SSL', 'Net::SSL POD coverage is go!' );
+ my @modules = qw(Crypt::SSLeay Crypt::SSLeay::Version Net::SSL);
+
+ eval "use Test::Pod::Coverage; 1" or skip(
+ 'Test::Pod::Coverage not installed on this system',
+ scalar @modules
+ );
+
+ pod_coverage_ok($_, "$_ POD coverage") for @modules;
+}
+
+{
+ my $ctx = main_ctx();
+ isa_ok($ctx, 'Crypt::SSLeay::CTX', 'main context');
}
-my $ctx = main_ctx();
-is(ref($ctx), 'Crypt::SSLeay::CTX', 'we have a context');
+done_testing();
use strict;
use Test::More tests => 8;
+use if ($^O ne 'MSWin32'), 'POSIX';
+eval "setlocale(LC_MESSAGES, 'C');" if $^O ne 'MSWin32';
use Net::SSL;
'getlines() not implemented'
);
- is( $sock->blocking, 1, 'socket is blocking' );
+ # RT #90803: Don't whether $sock->blocking returns 1 or 0.
+ # Instead, test true/false.
+ ok( $sock->blocking, 'socket is blocking' );
$sock->blocking(0);
- is( $sock->blocking, 0, 'socket is now non-blocking' );
+ ok( !$sock->blocking, 'socket is now non-blocking' );
}
# Make sure prerequisites are there
BEGIN {
- use_ok('Net::SSL');
+ # Make sure LWP uses us even when IO::Socket::SSL
+ # is installed.
+ $Net::HTTPS::SSL_SOCKET_CLASS = 'Net::SSL';
+ use_ok('HTTP::Request');
use_ok('LWP::UserAgent');
use_ok('LWP::Protocol::https');
- use_ok('HTTP::Request');
+ use_ok('Net::SSL');
}
use constant METHOD => 'HEAD';
};
if ($res->is_success) {
- pass($test_name);
+ pass($test_name) if isa_ok(
+ $res->header('Client-SSL-Socket-Class'),
+ 'Net::SSL',
+ );
}
else {
fail($test_name);
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use Test::More;
+use Crypt::SSLeay::Version qw(
+ openssl_built_on
+ openssl_cflags
+ openssl_dir
+ openssl_platform
+ openssl_version
+ openssl_version_number
+);
+
+{
+ my $built_on = openssl_built_on();
+ ok(defined $built_on, 'openssl_built_on returns a defined value');
+ note $built_on;
+ like(
+ $built_on,
+ qr/\Abuilt on:/,
+ 'openssl_built_on return value looks valid',
+ );
+}
+
+{
+ my $cflags = openssl_cflags();
+ ok(defined $cflags, 'openssl_cflags returns a defined value');
+ note $cflags;
+ like(
+ $cflags,
+ qr/\Acompiler:/,
+ 'openssl_cflags return value looks valid',
+ );
+}
+
+{
+ my $dir = openssl_dir();
+ ok(defined $dir, 'openssl_dir returns a defined value');
+ note $dir;
+ like(
+ $dir,
+ qr/\AOPENSSLDIR:/,
+ 'openssl_dir return value looks valid',
+ );
+}
+
+{
+ my $platform = openssl_platform();
+ ok(defined $platform, 'openssl_platform returns a defined value');
+ note $platform;
+ like(
+ $platform,
+ qr/\Aplatform:/,
+ 'openssl_platform return value looks valid',
+ );
+}
+
+{
+ my $version = openssl_version();
+ ok(defined $version, 'openssl_version returns a defined value');
+ note $version;
+ like(
+ $version,
+ qr/\AOpenSSL/,
+ 'openssl_version return value looks valid',
+ );
+}
+
+{
+ my $version_number = openssl_version_number();
+ ok(defined $version_number, 'openssl_int_version returns a defined value');
+ note sprintf('0x%08x', $version_number);
+ ok ($version_number >= 0x0922, 'OpenSSL version geq lowest known version');
+}
+
+warn_if_openssl_possibly_vulnerable_to_heartbleed();
+
+done_testing;
+
+# see https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160
+sub warn_if_openssl_possibly_vulnerable_to_heartbleed {
+ my %vulnerable = map { $_ => undef } (
+ 0x1000100f,
+ 0x1000101f,
+ 0x1000102f,
+ 0x1000103f,
+ 0x1000104f,
+ 0x1000105f,
+ 0x1000106f,
+ 0x10002001,
+ );
+
+ # not one of the vulnerable versions
+ return unless exists $vulnerable{ openssl_version_number() };
+
+ # vulnerable version, but heartbeats disabled, so immune
+ return if openssl_cflags =~ m{[-/]DOPENSSL_NO_HEARTBEATS};
+
+ my $version_string = openssl_version();
+ my $built_on = openssl_built_on();
+
+ diag(<<EO_DIAG
+ You have '$version_string'
+ built on '$built_on'
+ and SSL Heartbeats are not disabled.
+
+ That means your client may be vulnerable to a server exploiting the
+ Heartbleed bug unless the vulnerability was patched without changing
+ version. The vulnerability was disclosed on or about 2014/04/07. A
+ build date after that may indicate that the library you are using
+ may have been patched. You should check this.
+
+ The risk is compounded by the fact that Crypt::SSLeay does not
+ verify hosts. You can still force install Crypt::SSLeay, but you
+ need to be aware of this issue, and strongly consider upgrading to a
+ safer version of OpenSSL.
+
+ See also:
+
+ - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160
+ - http://isc.sans.edu/diary/17945
+ - http://seclists.org/fulldisclosure/2014/Apr/91
+EO_DIAG
+ );
+ return 1;
+}
--- /dev/null
+#!perl -T
+
+use 5.006;
+use strict;
+use warnings;
+use Path::Class;
+use Test::More;
+
+sub not_in_file_ok {
+ my ($filename, %regex) = @_;
+ open( my $fh, '<', $filename )
+ or die "couldn't open $filename for reading: $!";
+
+ my %violated;
+
+ while (my $line = <$fh>) {
+ while (my ($desc, $regex) = each %regex) {
+ if ($line =~ $regex) {
+ push @{$violated{$desc}||=[]}, $.;
+ }
+ }
+ }
+
+ if (%violated) {
+ fail("$filename contains boilerplate text");
+ diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
+ } else {
+ pass("$filename contains no boilerplate text");
+ }
+}
+
+sub module_boilerplate_ok {
+ my ($module) = @_;
+ not_in_file_ok($module =>
+ 'the great new $MODULENAME' => qr/ - The great new /,
+ 'boilerplate description' => qr/Quick summary of what the module/,
+ 'stub function definition' => qr/function[12]/,
+ );
+}
+
+
+not_in_file_ok('README.md' =>
+"The README is used..." => qr/The README is used/,
+"'version information here'" => qr/to provide version information/,
+);
+
+not_in_file_ok(Changes =>
+"placeholder date/time" => qr(Date/time)
+);
+
+module_boilerplate_ok(file qw(lib Crypt SSLeay Conn.pm));
+module_boilerplate_ok(file qw(lib Crypt SSLeay CTX.pm));
+module_boilerplate_ok(file qw(lib Crypt SSLeay Err.pm));
+module_boilerplate_ok(file qw(lib Crypt SSLeay MainContext.pm));
+module_boilerplate_ok(file qw(lib Crypt SSLeay Version.pm));
+module_boilerplate_ok(file qw(lib Crypt SSLeay X509.pm));
+
+module_boilerplate_ok(file qw(lib Net SSL.pm));
+
+done_testing;
--- /dev/null
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+unless ( $ENV{RELEASE_TESTING} ) {
+ plan( skip_all => "Author tests not required for installation" );
+}
+
+eval "use Test::CheckManifest 0.9";
+plan skip_all => "Test::CheckManifest 0.9 required" if $@;
+ok_manifest();