line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2012-2016 by [Mark Overmeer]. |
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.02. |
5
|
1
|
|
|
1
|
|
673
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
2
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package XML::Compile::WSS::SecToken::X509v3; |
9
|
1
|
|
|
1
|
|
2
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
10
|
|
|
|
|
|
|
$VERSION = '2.02'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
3
|
use base 'XML::Compile::WSS::SecToken'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
58
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
3
|
use Log::Report 'xml-compile-wss-sig'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
165
|
use XML::Compile::WSS::Util qw/XTP10_X509v3/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
3
|
use Scalar::Util qw/blessed/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
19
|
1
|
|
|
1
|
|
3
|
use Crypt::OpenSSL::X509 qw/FORMAT_ASN1 FORMAT_PEM/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
307
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub init($) |
23
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
24
|
0
|
0
|
|
|
|
|
$args->{cert_file} and panic "removed in 1.07, use fromFile()"; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
0
|
|
|
|
$args->{type} ||= XTP10_X509v3; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my $cert; |
29
|
0
|
0
|
|
|
|
|
if($cert = $args->{certificate}) {} |
|
|
0
|
|
|
|
|
|
30
|
|
|
|
|
|
|
elsif(my $bin = $args->{binary}) |
31
|
0
|
|
|
|
|
|
{ $cert = Crypt::OpenSSL::X509->new_from_string($bin, FORMAT_ASN1) } |
32
|
0
|
|
|
|
|
|
else { error __x"certificate or binary required for X509 token" } |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
0
|
|
|
|
blessed $cert && $cert->isa('Crypt::OpenSSL::X509') |
35
|
|
|
|
|
|
|
or error __x"X509 certificate object not supported (yet)"; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
0
|
|
|
|
$args->{name} ||= $cert->subject; |
38
|
0
|
|
0
|
|
|
|
$args->{fingerprint} ||= $cert->fingerprint_sha1; |
39
|
0
|
|
|
|
|
|
$self->SUPER::init($args); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$self->{XCWSX_cert} = $cert; |
42
|
0
|
|
|
|
|
|
$self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub fromFile($%) |
47
|
0
|
|
|
0
|
1
|
|
{ my ($class, $fn, %args) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# openssl's error message are a poor |
50
|
0
|
0
|
|
|
|
|
-f $fn or error __x"key file {fn} does not exist", fn => $fn; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
0
|
|
|
|
my $format = delete $args{format} || FORMAT_PEM; |
53
|
0
|
|
|
|
|
|
my $cert = eval { Crypt::OpenSSL::X509->new_from_file($fn, $format) }; |
|
0
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if($@) |
55
|
0
|
|
|
|
|
|
{ my $err = $@; |
56
|
0
|
|
|
|
|
|
$err =~ s/\. at.*//; |
57
|
0
|
|
|
|
|
|
error __x"in file {file}: {err}" , file => $fn, err => $err; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
$class->new(certificate => $cert, %args); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------ |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
sub certificate() {shift->{XCWSX_cert}} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
#------------------------ |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
0
|
1
|
|
sub asBinary() {shift->certificate->as_string(FORMAT_ASN1)} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |