-
Notifications
You must be signed in to change notification settings - Fork 5
/
VerifyX509.pm
94 lines (56 loc) · 1.98 KB
/
VerifyX509.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package Crypt::OpenSSL::VerifyX509;
use strict;
use warnings;
require 5.008_001;
our $VERSION = '0.10';
use Crypt::OpenSSL::X509;
BOOT_XS: {
require DynaLoader;
# DynaLoader calls dl_load_flags as a static method.
*dl_load_flags = DynaLoader->can('dl_load_flags');
do {__PACKAGE__->can('bootstrap') || \&DynaLoader::bootstrap}->(__PACKAGE__, $VERSION);
}
END {
__PACKAGE__->__X509_cleanup;
}
1;
__END__
=pod
=head1 NAME
Crypt::OpenSSL::VerifyX509 - simple certificate verification
=head1 SYNOPSIS
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);
=head1 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.
=head1 METHODS
=head2 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
=head2 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.
=head1 AUTHOR
Chris Andrews <chrisandrews@venda.com>
=head1 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.
=head1 LICENCE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut