line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
#include "ppport.h" |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x10100000 |
10
|
0
|
|
|
|
|
|
static const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x) |
11
|
|
|
|
|
|
|
{ |
12
|
0
|
|
|
|
|
|
return x->serialNumber; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
#endif |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
MODULE = POE::Filter::SSL PACKAGE = POE::Filter::SSL |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
long |
19
|
|
|
|
|
|
|
SSL_set_tmp_dh(ssl,dh) |
20
|
|
|
|
|
|
|
SSL * ssl |
21
|
|
|
|
|
|
|
DH * dh |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
long |
24
|
|
|
|
|
|
|
SSL_CTX_set_tmp_dh(ctx,dh) |
25
|
|
|
|
|
|
|
SSL_CTX * ctx |
26
|
|
|
|
|
|
|
DH * dh |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
long |
29
|
|
|
|
|
|
|
SSL_CTX_set_tmp_rsa(ctx,rsa) |
30
|
|
|
|
|
|
|
SSL_CTX * ctx |
31
|
|
|
|
|
|
|
RSA * rsa |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
ASN1_INTEGER * |
34
|
|
|
|
|
|
|
X509_get_serialNumber(cert) |
35
|
|
|
|
|
|
|
X509 * cert |
36
|
|
|
|
|
|
|
CODE: |
37
|
0
|
|
|
|
|
|
RETVAL = X509_get_serialNumber(cert); |
38
|
0
|
|
|
|
|
|
ST(0) = sv_newmortal(); /* Undefined to start with */ |
39
|
0
|
|
|
|
|
|
sv_setpvn( ST(0), RETVAL->data, RETVAL->length); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
ASN1_INTEGER * |
42
|
|
|
|
|
|
|
verify_serial_against_crl_file(crlfile, serial) |
43
|
|
|
|
|
|
|
CODE: |
44
|
0
|
|
|
|
|
|
X509_CRL *crl=NULL; |
45
|
|
|
|
|
|
|
X509_REVOKED *revoked; |
46
|
|
|
|
|
|
|
STACK_OF(X509_REVOKED) *revokes; |
47
|
0
|
|
|
|
|
|
BIO *in=NULL; |
48
|
0
|
|
|
|
|
|
int n,i,retval = 0; |
49
|
|
|
|
|
|
|
STRLEN len, lenser; |
50
|
0
|
0
|
|
|
|
|
unsigned char* crlfile = SvPV( ST(0), len); |
51
|
0
|
0
|
|
|
|
|
unsigned char* serial = SvPV( ST(1), lenser); |
52
|
0
|
|
|
|
|
|
ST(0) = sv_newmortal(); /* Undefined to start with */ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
/* check peer cert against CRL */ |
55
|
0
|
0
|
|
|
|
|
if (len <= 0) { |
56
|
0
|
|
|
|
|
|
sv_setpvn(ST(0), "CRL: No file name given!", 24); |
57
|
0
|
|
|
|
|
|
goto end; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
in=BIO_new(BIO_s_file()); |
61
|
0
|
0
|
|
|
|
|
if (in == NULL) { |
62
|
0
|
|
|
|
|
|
sv_setpvn(ST(0), "CRL: BIO err", 12); |
63
|
0
|
|
|
|
|
|
goto end; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if (BIO_read_filename(in, crlfile) <= 0) { |
67
|
0
|
|
|
|
|
|
sv_setpvn(ST(0), "CRL: cannot read CRL File", 25); |
68
|
0
|
|
|
|
|
|
goto end; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
crl=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL); |
72
|
0
|
0
|
|
|
|
|
if (crl == NULL) { |
73
|
0
|
|
|
|
|
|
sv_setpvn(ST(0), "CRL: cannot read from CRL File", 30); |
74
|
0
|
|
|
|
|
|
goto end; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
revokes = X509_CRL_get_REVOKED(crl); |
78
|
0
|
|
|
|
|
|
n = sk_X509_REVOKED_num(revokes); |
79
|
0
|
0
|
|
|
|
|
if (n > 0) { |
80
|
0
|
0
|
|
|
|
|
for (i = 0; i < n; i++) { |
81
|
|
|
|
|
|
|
const ASN1_INTEGER *asn_ser; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
revoked = sk_X509_REVOKED_value(revokes, i); |
84
|
0
|
|
|
|
|
|
asn_ser = X509_REVOKED_get0_serialNumber(revoked); |
85
|
0
|
0
|
|
|
|
|
if ( (asn_ser->length > 0) && |
|
|
0
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
(asn_ser->length == lenser) && |
87
|
0
|
|
|
|
|
|
(strncmp(asn_ser->data, serial, lenser) == 0)) { |
88
|
0
|
|
|
|
|
|
sv_setpvn( ST(0), asn_ser->data, asn_ser->length); |
89
|
0
|
|
|
|
|
|
goto end; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
|
|
|
|
sv_setpvn(ST(0), "0", 1); |
93
|
|
|
|
|
|
|
} else { |
94
|
0
|
|
|
|
|
|
sv_setpvn(ST(0), "CRL: Empty File", 15); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
end: |
97
|
0
|
|
|
|
|
|
BIO_free(in); |
98
|
0
|
0
|
|
|
|
|
if (crl) X509_CRL_free (crl); |