| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#+############################################################################## |
|
2
|
|
|
|
|
|
|
# # |
|
3
|
|
|
|
|
|
|
# File: Authen/Credential/x509.pm # |
|
4
|
|
|
|
|
|
|
# # |
|
5
|
|
|
|
|
|
|
# Description: abstraction of an X.509 credential # |
|
6
|
|
|
|
|
|
|
# # |
|
7
|
|
|
|
|
|
|
#-############################################################################## |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# module definition |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
package Authen::Credential::x509; |
|
14
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
95
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = "1.0_1"; |
|
17
|
|
|
|
|
|
|
our $REVISION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# inheritance |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @ISA = qw(Authen::Credential); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# used modules |
|
27
|
|
|
|
|
|
|
# |
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
4
|
use Authen::Credential qw(); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
16
|
|
|
30
|
1
|
|
|
1
|
|
4
|
use Params::Validate qw(validate_pos :types); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
279
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# |
|
33
|
|
|
|
|
|
|
# Params::Validate specification |
|
34
|
|
|
|
|
|
|
# |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$Authen::Credential::ValidationSpec{x509} = { |
|
37
|
|
|
|
|
|
|
cert => { type => SCALAR, optional => 1 }, |
|
38
|
|
|
|
|
|
|
key => { type => SCALAR, optional => 1 }, |
|
39
|
|
|
|
|
|
|
ca => { type => SCALAR, optional => 1 }, |
|
40
|
|
|
|
|
|
|
ca_file => { type => SCALAR, optional => 1 }, |
|
41
|
|
|
|
|
|
|
pass => { type => SCALAR, optional => 1 }, |
|
42
|
|
|
|
|
|
|
}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# |
|
45
|
|
|
|
|
|
|
# accessors |
|
46
|
|
|
|
|
|
|
# |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
foreach my $name (qw(cert key ca ca_file pass)) { |
|
49
|
1
|
|
|
1
|
|
6
|
no strict "refs"; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
384
|
|
|
50
|
|
|
|
|
|
|
*{ $name } = sub { |
|
51
|
5
|
|
|
5
|
|
6
|
my($self); |
|
52
|
5
|
|
|
|
|
6
|
$self = shift(@_); |
|
53
|
5
|
50
|
|
|
|
80
|
validate_pos(@_) if @_; |
|
54
|
5
|
|
|
|
|
21
|
return($self->{$name}); |
|
55
|
|
|
|
|
|
|
}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# |
|
59
|
|
|
|
|
|
|
# preparators |
|
60
|
|
|
|
|
|
|
# |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$Authen::Credential::Preparator{x509}{"IO::Socket::SSL"} = sub { |
|
63
|
|
|
|
|
|
|
my($self, %data); |
|
64
|
|
|
|
|
|
|
$self = shift(@_); |
|
65
|
|
|
|
|
|
|
validate_pos(@_) if @_; |
|
66
|
|
|
|
|
|
|
foreach my $tmp ($self->cert(), $ENV{X509_USER_CERT}) { |
|
67
|
|
|
|
|
|
|
next unless defined($tmp); |
|
68
|
|
|
|
|
|
|
$data{SSL_cert_file} = $tmp; |
|
69
|
|
|
|
|
|
|
last; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
foreach my $tmp ($self->key(), $ENV{X509_USER_KEY}) { |
|
72
|
|
|
|
|
|
|
next unless defined($tmp); |
|
73
|
|
|
|
|
|
|
$data{SSL_key_file} = $tmp; |
|
74
|
|
|
|
|
|
|
last; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
foreach my $tmp ($self->ca(), $ENV{X509_CERT_DIR}) { |
|
77
|
|
|
|
|
|
|
next unless defined($tmp); |
|
78
|
|
|
|
|
|
|
$data{SSL_ca_path} = $tmp; |
|
79
|
|
|
|
|
|
|
last; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
foreach my $tmp ($self->ca_file(), $ENV{X509_CERT_FILE}) { |
|
82
|
|
|
|
|
|
|
next unless defined($tmp); |
|
83
|
|
|
|
|
|
|
$data{SSL_ca_file} = $tmp; |
|
84
|
|
|
|
|
|
|
last; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
$data{SSL_passwd_cb} = sub { return($self->pass()) } |
|
87
|
|
|
|
|
|
|
if defined($self->pass()); |
|
88
|
|
|
|
|
|
|
$data{SSL_use_cert} = 1 if $data{SSL_cert_file} and $data{SSL_key_file}; |
|
89
|
|
|
|
|
|
|
return(\%data); |
|
90
|
|
|
|
|
|
|
}; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__DATA__ |