forked from chrisa/perl-Crypt-OpenSSL-VerifyX509
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
714 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
name: macos-10.15 | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags-ignore: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- '*' | ||
jobs: | ||
perl: | ||
# REF: https://github.com/actions/virtual-environments | ||
runs-on: macOS-10.15 | ||
|
||
strategy: | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# REF: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md (see link above, at the time of writing we get Perl 5.34.0 with macOS 10.15) | ||
- name: Set up Perl | ||
run: | | ||
brew install perl | ||
curl https://cpanmin.us | perl - App::cpanminus -n | ||
echo "/Users/runner/perl5/bin" >> $GITHUB_PATH | ||
- name: perl -V | ||
run: perl -V | ||
|
||
- name: Run Tests | ||
run: | | ||
curl -sL https://cpanmin.us/ | perl - -nq --with-develop --installdeps -v . | ||
perl Makefile.PL | ||
make | ||
make test |
2 changes: 1 addition & 1 deletion
2
.github/workflows/macos.yml → .github/workflows/macos-latest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
name: macos | ||
name: macos-latest | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ VerifyX509.o | |
VerifyX509.c | ||
VerifyX509.bs | ||
SIGNATURE | ||
Crypt-OpenSSL-VerifyX509* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,100 @@ | ||
#!/usr/bin/env perl | ||
# This Makefile.PL for Crypt-OpenSSL-VerifyX509 was generated by | ||
# Dist::Zilla::Plugin::MakeMaker::Awesome 0.49. | ||
# Don't edit it but the dist.ini and plugins used to construct it. | ||
|
||
use strict; | ||
use warnings; | ||
|
||
BEGIN { unshift @INC, '.' } | ||
|
||
use inc::Module::Install 0.91; | ||
use Module::Install::AuthorRequires; | ||
use Module::Install::AuthorTests; | ||
use 5.008; | ||
use ExtUtils::MakeMaker; | ||
|
||
use Config; | ||
use File::Spec; | ||
|
||
sub search_lib { | ||
my ($lib) = @_; | ||
unless ($lib =~ /^-l/) { | ||
warn "search_lib: illegal arguments, \`$lib\'.\n"; | ||
return undef; | ||
} | ||
my $libbase = 'lib' . substr($lib, 2) . $Config{lib_ext}; | ||
my $libbase_so = 'lib' . substr($lib, 2) . "." . $Config{so}; | ||
my $libbase_cyg = 'lib' . substr($lib, 2) . ".dll" . $Config{lib_ext}; | ||
my @paths = split(' ', $Config{libpth}); | ||
push @paths, $ENV{PERL_LIBPATH} if exists $ENV{PERL_LIBPATH}; | ||
for my $path (@paths) { | ||
if (-f $path . '/' . $libbase) { | ||
print "$path/$libbase\n"; | ||
print "Found '$path/$libbase'.\n"; | ||
return $lib; | ||
} elsif (-f $path . '/' . $libbase_so) { | ||
print "$path/$libbase_so\n"; | ||
print "Found `$path/$libbase_so'.\n"; | ||
return $lib; | ||
} elsif (-f $path . '/' . $libbase_cyg) { | ||
print "$path/$libbase_cyg\n"; | ||
print "Found `$path/$libbase_cyg'.\n"; | ||
return $lib; | ||
} | ||
} | ||
return undef; | ||
} | ||
|
||
if (!defined search_lib('-lcrypto')) { | ||
warn "* libcrypto is not installed or not in the default lib path. Aborting.\n"; | ||
exit; | ||
} | ||
|
||
name 'Crypt-OpenSSL-VerifyX509'; | ||
license 'perl'; | ||
all_from 'VerifyX509.pm'; | ||
|
||
requires_external_cc(); | ||
|
||
if (-d "/usr/include/openssl") { | ||
cc_inc_paths('/usr/include/openssl'); | ||
cc_lib_paths('/usr/lib'); | ||
} elsif (-d "/usr/local/include/ssl") { | ||
cc_inc_paths('/usr/local/include/ssl'); | ||
cc_lib_paths('/usr/local/lib/ssl'); | ||
} elsif (-d "/usr/local/ssl/include") { | ||
cc_inc_paths('/usr/local/ssl/include'); | ||
cc_lib_paths('/usr/local/ssl/lib'); | ||
} elsif (-d "/usr/local/opt/openssl/include") { | ||
cc_inc_paths('/usr/local/opt/openssl/include'); | ||
} | ||
my %args; | ||
|
||
my $ccflags = ''; | ||
if ($Config::Config{ccname} =~ /gcc/i) { | ||
$ccflags = $ENV{AUTHOR_TESTING} ? '-Wall -Werror': '-Wall'; | ||
if ($^O ne 'MSWin32' and my $prefix = `brew --prefix --installed openssl\@1.1 2>@{[File::Spec->devnull]}`) { | ||
chomp $prefix; | ||
$args{INC} = "-I$prefix/include"; | ||
$args{LIBS} = ["-L$prefix/lib -lcrypto -lssl"]; | ||
} else { | ||
$ccflags = ''; | ||
$args{INC} = '-I/usr/local/opt/openssl/include -I/usr/local/include/openssl -I/usr/include/openssl -I/usr/local/include/ssl -I/usr/local/ssl/include'; | ||
$args{LIBS} = ['-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/lib -L/usr/local/ssl/lib -lcrypto -lssl']; | ||
} | ||
|
||
if (($Config::Config{myuname} =~ /sunos|solaris/i) && ($Config::Config{PATCHLEVEL} =~ /5.20/)) { | ||
cc_lib_links('crypto'); | ||
cc_optimize_flags("-O3 -DOPENSSL_API_COMPAT=0x10100000L"); | ||
} elsif ($Config::Config{myuname} =~ /darwin/i) { | ||
cc_optimize_flags("-O3 -DOPENSSL_API_COMPAT=0x10100000L"); | ||
} else { | ||
cc_lib_links('crypto'); | ||
cc_optimize_flags("-O3 $ccflags -DOPENSSL_API_COMPAT=0x10100000L"); | ||
if ($^O eq 'MSWin32') { | ||
if (my $libs = `pkg-config --libs libcrypto 2>nul`) { | ||
# strawberry perl has pkg-config | ||
$args{LIBS} = [ $libs ]; | ||
} else { | ||
$args{LIBS} = ['-llibeay32'] if $Config{cc} =~ /cl/; # msvc with ActivePerl | ||
$args{LIBS} = ['-leay32'] if $Config{gccversion}; # gcc | ||
} | ||
} | ||
|
||
requires 'Crypt::OpenSSL::X509' => '1.807'; | ||
my $cc_option_flags = '-O2 -g -Wall -Werror -DOPENSSL_API_COMPAT=0x10100000L'; | ||
|
||
author_requires 'Test::NoTabs'; | ||
author_requires 'Test::Pod' => '1.14'; | ||
author_requires 'Test::Pod::Coverage' => '1.04'; | ||
if ($Config{gccversion} =~ /llvm/i) { | ||
if ( $^O eq 'darwin' && $Config{gccversion} =~ /LLVM 12.0.5/) { | ||
$cc_option_flags .= ' -Wno-deprecated-declarations -Wno-compound-token-split-by-macro'; | ||
} else { | ||
$cc_option_flags .= ' -Wno-deprecated-declarations'; | ||
} | ||
|
||
test_requires 'Test::More' => '0.88'; | ||
test_requires 'File::Slurper'; | ||
test_requires 'Test::Exception'; | ||
if ($Config{gccversion} =~ /llvm 13/i) { | ||
$cc_option_flags .= ' -Wno-compound-token-split-by-macro'; | ||
} | ||
|
||
resources | ||
license => "http://dev.perl.org/licenses", | ||
bugtracker => "http://rt.cpan.org/NoAuth/Bugs.html?Dist=Crypt-OpenSSL-VerifyX509", | ||
repository => "http://github.com/timlegge/perl-Crypt-OpenSSL-VerifyX509"; | ||
if ($Config{perl_version} <= 20) { | ||
$cc_option_flags .= ' -Wno-error=pointer-bool-conversion'; | ||
} | ||
} | ||
|
||
if ($Config{myuname} =~ /sunos|solaris/i) { | ||
# Any SunStudio flags? | ||
} else { | ||
$args{OPTIMIZE} = $cc_option_flags; | ||
} | ||
|
||
author_tests 't/author'; | ||
my %WriteMakefileArgs = ( | ||
"ABSTRACT" => "simple certificate verification", | ||
"AUTHOR" => "Chris Andrews", | ||
"CONFIGURE_REQUIRES" => { | ||
"ExtUtils::MakeMaker" => 0 | ||
}, | ||
"DISTNAME" => "Crypt-OpenSSL-VerifyX509", | ||
"LICENSE" => "perl", | ||
"MIN_PERL_VERSION" => "5.008", | ||
"NAME" => "Crypt::OpenSSL::VerifyX509", | ||
"PREREQ_PM" => { | ||
"Crypt::OpenSSL::X509" => 0 | ||
}, | ||
"TEST_REQUIRES" => { | ||
"File::Slurper" => "0.012" | ||
}, | ||
"VERSION" => "0.17", | ||
"test" => { | ||
"TESTS" => "t/*.t" | ||
} | ||
); | ||
|
||
%WriteMakefileArgs = ( | ||
%WriteMakefileArgs, | ||
%args, | ||
); | ||
|
||
my %FallbackPrereqs = ( | ||
"Crypt::OpenSSL::X509" => 0, | ||
"File::Slurper" => "0.012" | ||
); | ||
|
||
unless ( eval { ExtUtils::MakeMaker->VERSION('6.63_03') } ) { | ||
delete $WriteMakefileArgs{TEST_REQUIRES}; | ||
delete $WriteMakefileArgs{BUILD_REQUIRES}; | ||
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs; | ||
} | ||
|
||
WriteAll(); | ||
delete $WriteMakefileArgs{CONFIGURE_REQUIRES} | ||
unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; | ||
|
||
WriteMakefile(%WriteMakefileArgs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# NAME | ||
|
||
Crypt::OpenSSL::VerifyX509 - simple certificate verification | ||
|
||
# SYNOPSIS | ||
|
||
```perl | ||
use Crypt::OpenSSL::VerifyX509; | ||
use Crypt::OpenSSL::X509; | ||
|
||
my $ca = Crypt::OpenSSL::VerifyX509->new('t/cacert.pem'); | ||
|
||
my $cert = Crypt::OpenSSL::X509->new(...); | ||
$ca->verify($cert); | ||
``` | ||
|
||
# DESCRIPTION | ||
|
||
Given a CA certificate and another untrusted certificate, will show | ||
whether the CA signs the certificate. This is a useful thing to have | ||
if you're signing with X509 certificates, but outside of SSL. | ||
|
||
A specific example is where you're working with XML signatures, and | ||
need to verify that the signing certificate is valid. | ||
|
||
You could use Crypt::OpenSSL::CA to do this, but it is based on | ||
Inline::C, which can be troublesome in some situations. This module | ||
provides an XS alternative for the certificate verify feature. | ||
|
||
# METHODS | ||
|
||
## new($ca\_path) | ||
|
||
Constructor. Returns a VerifyX509 instance, set up with the given CA. | ||
|
||
Arguments: | ||
|
||
``` | ||
* $ca_path - path to a file containing the CA certificate | ||
``` | ||
|
||
## verify($cert) | ||
|
||
Verify the certificate is signed by the CA. Returns true if so, and | ||
croaks with the verification error if not. | ||
|
||
Arguments: | ||
|
||
``` | ||
* $cert - a Crypt::OpenSSL::X509 object for the certificate to verify. | ||
``` | ||
|
||
# AUTHOR | ||
|
||
Chris Andrews <chrisandrews@venda.com> | ||
|
||
# MAINTAINER | ||
|
||
Timothy Legge <timlegge@gmail.com> | ||
|
||
# COPYRIGHT | ||
|
||
The following copyright notice applies to all the files provided in | ||
this distribution, including binary files, unless explicitly noted | ||
otherwise. | ||
|
||
Copyright 2010 Venda Ltd. | ||
|
||
# LICENCE | ||
|
||
This library is free software; you can redistribute it and/or modify | ||
it under the same terms as Perl itself. |
Oops, something went wrong.