File Coverage

blib/lib/Crypt/OpenSSL/Verify.pm
Criterion Covered Total %
statement 16 23 69.5
branch 3 18 16.6
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 25 47 53.1


line stmt bran cond sub pod time code
1             package Crypt::OpenSSL::Verify;
2              
3 8     8   486925 use strict;
  8         83  
  8         239  
4 8     8   58 use warnings;
  8         25  
  8         398  
5              
6             require 5.010;
7              
8             our $VERSION = '0.36';
9              
10 8     8   4181 use Crypt::OpenSSL::X509;
  8         338193  
  8         2273  
11              
12             BOOT_XS: {
13             require DynaLoader;
14              
15             # DynaLoader calls dl_load_flags as a static method.
16             *dl_load_flags = DynaLoader->can('dl_load_flags');
17              
18             do { __PACKAGE__->can('bootstrap') || \&DynaLoader::bootstrap }
19             ->( __PACKAGE__, $VERSION );
20             }
21              
22             # Register the sub pcb1
23             register_verify_cb( \&verify_callback );
24              
25             sub verify_callback {
26 8     8 1 3463 my ( $ok, $ctx ) = @_;
27 8         26 my $cert_error = ctx_error_code($ctx);
28              
29 8 100       24 if ( !$ok ) {
30 2 50       7 if ( $cert_error == 10 ) {
    0          
    0          
    0          
    0          
    0          
    0          
    0          
31             # X509_V_ERR_CERT_HAS_EXPIRED:
32 2         5 $ok = 1;
33             }
34             elsif ( $cert_error == 18 ) {
35             # X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
36 0         0 $ok = $ok; # Disabled not in Verify509
37             }
38             elsif ( $cert_error == 24 ) {
39             # X509_V_ERR_INVALID_CA:
40 0         0 $ok = 1;
41             }
42             elsif ( $cert_error == 25 ) {
43             # X509_V_ERR_PATH_LENGTH_EXCEEDED:
44 0         0 $ok = 1;
45             }
46             elsif ( $cert_error == 26 ) {
47             # X509_V_ERR_INVALID_PURPOSE:
48 0         0 $ok = 1;
49             }
50             elsif ( $cert_error == 12 ) {
51             # X509_V_ERR_CRL_HAS_EXPIRED:
52 0         0 $ok = 1;
53             }
54             elsif ( $cert_error == 11 ) {
55             # X509_V_ERR_CRL_NOT_YET_VALID:
56 0         0 $ok = 1;
57             }
58             elsif ( $cert_error == 34 ) {
59             # X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION:
60 0         0 $ok = 1;
61             }
62              
63             # Disabled for Crypt::OpenSSL::VerifyX509 Compatability
64             #elsif ($cert_error == 21) {
65             # # X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
66             # $ok = 1;
67             #}
68             #elsif ($cert_error == 20) {
69             # # X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
70             # $ok = 1;
71             #}
72             #elsif ($cert_error == 43) {
73             # # X509_V_ERR_NO_EXPLICIT_POLICY
74             # $ok = 1;
75             #}
76             #elsif ($cert_error == 37) {
77             # # X509_V_ERR_INVALID_NON_CA:
78             # $ok = 1;
79             #}
80             }
81              
82 8         987 return $ok;
83              
84             }
85              
86             END {
87 8     8   25856 __PACKAGE__->__X509_cleanup;
88             }
89              
90             1;
91              
92             __END__