Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
package Crypt::SSLeay::CTX;
require Crypt::SSLeay;
use strict;
1;

View File

@@ -0,0 +1,4 @@
package Crypt::SSLeay::Conn;
require Crypt::SSLeay;
use strict;
1;

View File

@@ -0,0 +1,4 @@
package Crypt::SSLeay::Err;
require Crypt::SSLeay;
use strict;
1;

View File

@@ -0,0 +1,42 @@
package Crypt::SSLeay::MainContext;
# maintains a single instance of the Crypt::SSLeay::CTX class
use strict;
use Carp ();
require Crypt::SSLeay::CTX;
my $ctx = &main_ctx();
sub main_ctx {
my $ssl_version = shift || 23;
my $ctx = Crypt::SSLeay::CTX->new($ssl_version);
$ctx->set_cipher_list($ENV{CRYPT_SSLEAY_CIPHER})
if $ENV{CRYPT_SSLEAY_CIPHER};
$ctx;
}
my %sub_cache = ('main_ctx' => \&main_ctx );
sub import {
my $pkg = shift;
my $callpkg = caller();
my @func = @_;
for (@func) {
s/^&//;
Carp::croak("Can't export $_ from $pkg") if /\W/;;
my $sub = $sub_cache{$_};
unless ($sub) {
my $method = $_;
$method =~ s/^main_ctx_//; # optional prefix
$sub = $sub_cache{$_} = sub { $ctx->$method(@_) };
}
no strict 'refs';
*{"${callpkg}::$_"} = $sub;
}
}
1;

View File

@@ -0,0 +1,87 @@
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>.

View File

@@ -0,0 +1,26 @@
package Crypt::SSLeay::X509;
use strict;
sub not_before {
my $cert = shift;
not_string2time($cert->get_notBeforeString);
}
sub not_after {
my $cert = shift;
not_string2time($cert->get_notAfterString);
}
sub not_string2time {
my $string = shift;
# $string has the form 021019235959Z
my($year, $month, $day, $hour, $minute, $second, $GMT)=
$string=~m/(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(Z)?/;
$year += 2000;
my $time="$year-$month-$day $hour:$minute:$second";
$time .= " GMT" if $GMT;
$time;
}
1;