line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!perl -w |
2
|
|
|
|
|
|
|
# -*- coding: utf-8; -*- |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
286
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Crypt::OpenSSL::CA::Inline::C; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Crypt::OpenSSL::CA::Inline::C - A bag of XS and L tricks |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=for My::Tests::Below "synopsis" begin |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package Crypt::OpenSSL::CA::Foo; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Crypt::OpenSSL::CA::Inline::C <<"C_CODE_SAMPLE"; |
20
|
|
|
|
|
|
|
#include |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
static |
23
|
|
|
|
|
|
|
SV* mysub() { |
24
|
|
|
|
|
|
|
// Your C code here |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
C_CODE_SAMPLE |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# Then maybe some Perl... |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
use Crypt::OpenSSL::CA::Inline::C <<"MORE_C_CODE"; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
static |
34
|
|
|
|
|
|
|
void another() { |
35
|
|
|
|
|
|
|
// ... |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
MORE_C_CODE |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use Crypt::OpenSSL::CA::Inline::C "__END__"; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=for My::Tests::Below "synopsis" end |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
B
|
47
|
|
|
|
|
|
|
I. It is of no interest for people who just want |
48
|
|
|
|
|
|
|
to use the module.> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This package provides L goodness to L |
51
|
|
|
|
|
|
|
during development, plus a few tricks of our own. The idiom in |
52
|
|
|
|
|
|
|
L, used throughout the source code of |
53
|
|
|
|
|
|
|
L, recaps them all; noteworthy points are: |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item the C-newline trick |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Because the C language doesn't have namespaces, we don't want symbols |
60
|
|
|
|
|
|
|
named e.g. C appearing in the .so's symbol tables: they could |
61
|
|
|
|
|
|
|
clash with other symbols defined by Perl, or with each other. |
62
|
|
|
|
|
|
|
Therefore we have to declare them C, but doing this in the |
63
|
|
|
|
|
|
|
naïve way would cause L to purposefully B bind them |
64
|
|
|
|
|
|
|
with Perl... The winning trick is to put the C word alone on |
65
|
|
|
|
|
|
|
its line, as demonstrated. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item the "__END__" pragma |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The code in L must use the following pragma to |
70
|
|
|
|
|
|
|
signal that it won't attempt to add any L code after this |
71
|
|
|
|
|
|
|
point: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
use Crypt::OpenSSL::CA::Inline::C "__END__"; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 Standard Library |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
In addition to the standard library available to XS C code described |
80
|
|
|
|
|
|
|
in L, L, L and L, C code that |
81
|
|
|
|
|
|
|
compiles itself through I has access to |
82
|
|
|
|
|
|
|
the following C functions: |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head3 char0_value |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
static inline char* char0_value(SV* string); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Returns the string value of a Perl SV, making sure that it exists and |
89
|
|
|
|
|
|
|
is zero-terminated beforehand. If C is undef, returns the |
90
|
|
|
|
|
|
|
empty string (B NULL; see L). See |
91
|
|
|
|
|
|
|
L, look for the word "Nevertheless" - I'm |
92
|
|
|
|
|
|
|
pretty sure there is a macro in Perl's convenience stuff that does |
93
|
|
|
|
|
|
|
exactly that already, but I don't know it... |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head3 char0_value_or_null |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
static inline char* char0_value_or_null(SV* string); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Like L, except that NULL is returned if C is |
100
|
|
|
|
|
|
|
undef. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head3 perl_wrap |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
static inline SV* perl_wrap(class, pointer); |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Creates read-only SV containing the integral value of C, |
107
|
|
|
|
|
|
|
blesses it into class C and returns it as a SV*. The return |
108
|
|
|
|
|
|
|
value is an adequate Perl wrapper to stand for C, as |
109
|
|
|
|
|
|
|
demonstrated in L. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head3 perl_unwrap (class, typename, SV*) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
The reverse of L. Given a Lped SV*, asserts |
114
|
|
|
|
|
|
|
that it actually contains an object blessed in class C (lest it |
115
|
|
|
|
|
|
|
Cs), extracts the pointer within same, casts it into |
116
|
|
|
|
|
|
|
C and returns it. This is a macro instead of a static |
117
|
|
|
|
|
|
|
inline, so as to be able to perform the polymorphic cast. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head3 openssl_string_to_SV |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
static inline SV* openssl_string_to_SV(char* string); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Copies over C to a newly-allocated C Perl scalar, and |
124
|
|
|
|
|
|
|
then frees C using C. Used to transfer |
125
|
|
|
|
|
|
|
ownership of strings from OpenSSL to Perl, and thereby ensure proper |
126
|
|
|
|
|
|
|
memory management. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Note to I hackers: if C is on an OpenSSL |
129
|
|
|
|
|
|
|
static buffer instead of having been allocated by OpenSSL, this will |
130
|
|
|
|
|
|
|
SEGV in trying to free() C that was not malloc()'d; in this |
131
|
|
|
|
|
|
|
case you want to use L instead or some such. |
132
|
|
|
|
|
|
|
Check the OpenSSL documentation carefully, and make use of |
133
|
|
|
|
|
|
|
L to ascertain experimentally |
134
|
|
|
|
|
|
|
that your code doesn't leak memory. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head3 openssl_buf_to_SV |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
static inline SV* openssl_buf_to_SV(char* string, int length); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Like L except that the length is specified, |
141
|
|
|
|
|
|
|
which allows for C to not contain null characters or not be |
142
|
|
|
|
|
|
|
zero-terminated. Use this form e.g. for ASN.1 buffers returned by |
143
|
|
|
|
|
|
|
C OpenSSL functions. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head3 BIO_mem_to_SV |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
static inline SV* BIO_mem_to_SV(BIO *bio); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This inline function is intended to be used to return scalar values |
150
|
|
|
|
|
|
|
(e.g. PEM strings and RSA moduli) constructed by OpenSSL. Should be |
151
|
|
|
|
|
|
|
invoked thusly, after having freed all temporary resources except |
152
|
|
|
|
|
|
|
*bio: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
return BIO_mem_to_SV(bio); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
I turns bio into a Perl scalar and returns it, or |
157
|
|
|
|
|
|
|
Cs trying (hence the requirement not to have any outstanding |
158
|
|
|
|
|
|
|
memory resources allocated in the caller). Regardless of the outcome, |
159
|
|
|
|
|
|
|
C will be C()d. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 sslcroak |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
static void sslcroak(char *format, ...); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Like L, except that a blessed exception of class |
166
|
|
|
|
|
|
|
I is generated. The OpenSSL error |
167
|
|
|
|
|
|
|
stack, if any, gets recorded as an array reference inside the |
168
|
|
|
|
|
|
|
exception structure. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Note to I hackers: please select the appropriate |
171
|
|
|
|
|
|
|
routine between I and I, depending on whether the |
172
|
|
|
|
|
|
|
current error condition is being caused by OpenSSL or not; in this way |
173
|
|
|
|
|
|
|
callers are able to discriminate errors. Also, don't be fooled into |
174
|
|
|
|
|
|
|
thinking that C-style error management acts in the same way in |
175
|
|
|
|
|
|
|
C and Perl! Because calling C (or, for that matter, |
176
|
|
|
|
|
|
|
L) will return control directly to Perl without running |
177
|
|
|
|
|
|
|
any C code, any and all temporary variables that have been allocated |
178
|
|
|
|
|
|
|
from C will fail to be de-allocated, thereby causing a memory leak. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Internally, I works by invoking |
181
|
|
|
|
|
|
|
L several times, using a rough |
182
|
|
|
|
|
|
|
equivalent of the following pseudo-code: |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
_sslcroak_callback("-message", $formattedstring); |
185
|
|
|
|
|
|
|
_sslcroak_callback("-openssl", $openssl_errorstring_1); |
186
|
|
|
|
|
|
|
_sslcroak_callback("-openssl", $openssl_errorstring_2); |
187
|
|
|
|
|
|
|
... |
188
|
|
|
|
|
|
|
_sslcroak_callback("DONE"); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
where $formattedstring is the C-formatted version of the |
191
|
|
|
|
|
|
|
arguments passed to I, and the OpenSSL error strings are |
192
|
|
|
|
|
|
|
retrieved using B and B. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head3 parse_RFC3280_time |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
static ASN1_TIME* parse_RFC3280_time(char* datetime, |
197
|
|
|
|
|
|
|
char** errmsg, char* sslerrmsg); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Parses C, a date in "Zulu" format (that is, yyyymmddhhmmssZ, |
200
|
|
|
|
|
|
|
with a literal Z at the end), and returns a newly-allocated ASN1_TIME* |
201
|
|
|
|
|
|
|
structure utilizing a C encoding for dates in the year 2049 |
202
|
|
|
|
|
|
|
or before and C for dates in 2050 and after. RFC3280 |
203
|
|
|
|
|
|
|
dictates that this convention should apply to most date-related fields |
204
|
|
|
|
|
|
|
in X509 certificates and CRLs (as per sections 4.1.2.5 for certificate |
205
|
|
|
|
|
|
|
validity periods, and 5.1.2.4 through 5.1.2.6 for CRL validity periods |
206
|
|
|
|
|
|
|
and certificate revocation times). By contrast, the C |
207
|
|
|
|
|
|
|
CRL revocation reason extension is always in C and |
208
|
|
|
|
|
|
|
this function should not be used there. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
If there is an error, NULL is returned, and one (and only |
211
|
|
|
|
|
|
|
one) of *errmsg and *sslerrmsg is set to an error string, provided |
212
|
|
|
|
|
|
|
that they are not NULL. Caller should thereafter call I or |
213
|
|
|
|
|
|
|
L respectively. |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head3 parse_RFC3280_time_or_croak |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
static ASN1_TIME* parse_RFC3280_time_or_croak(char* datetime); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Like L except that it handles its errors itself and |
220
|
|
|
|
|
|
|
will therefore never return NULL. The caller should not have an |
221
|
|
|
|
|
|
|
outstanding temporary variable that must be freed before it returns, |
222
|
|
|
|
|
|
|
or a memory leak will be created; if this is the case, use the more |
223
|
|
|
|
|
|
|
clunky L form instead. |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head3 parse_serial |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
static ASN1_INTEGER* parse_serial |
228
|
|
|
|
|
|
|
(char* hexserial, char** errmsg, char** sslerrmsg); |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
Parses hexserial, a lowercase, hexadecimal string that starts with |
231
|
|
|
|
|
|
|
"0x", and returns it as a newly-allocated C structure |
232
|
|
|
|
|
|
|
that must be freed by caller (with C) when done |
233
|
|
|
|
|
|
|
with it. If there is an error, NULL is returned, and one (and only |
234
|
|
|
|
|
|
|
one) of *errmsg and *sslerrmsg is set to an error string, provided |
235
|
|
|
|
|
|
|
that they are not NULL. Caller should thereafter call I or |
236
|
|
|
|
|
|
|
L respectively. |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head3 parse_serial_or_croak |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
static ASN1_INTEGER* parse_serial_or_croak(char* hexserial); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Like L except that it handles its errors itself and |
243
|
|
|
|
|
|
|
will therefore never return NULL. The caller should not have an |
244
|
|
|
|
|
|
|
outstanding temporary variable that must be freed before it returns, |
245
|
|
|
|
|
|
|
or a memory leak will be created; if this is the case, use the more |
246
|
|
|
|
|
|
|
clunky L form instead. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=cut |
249
|
|
|
|
|
|
|
|
250
|
0
|
|
|
0
|
|
|
sub _c_boilerplate { <<'C_BOILERPLATE'; } |
251
|
|
|
|
|
|
|
#include /* For varargs stuff in sslcroak() */ |
252
|
|
|
|
|
|
|
#include /* For OPENSSL_free() in openssl_buf_to_SV */ |
253
|
|
|
|
|
|
|
#include /* For ERR_stuff in sslcroak() */ |
254
|
|
|
|
|
|
|
#include /* For BUF_MEM->data dereference in |
255
|
|
|
|
|
|
|
BIO_mem_to_SV(). WTF is this declaration |
256
|
|
|
|
|
|
|
doing in there?! */ |
257
|
|
|
|
|
|
|
#include /* Also for BIO_mem_to_SV() */ |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
#include |
260
|
|
|
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x00907000 |
261
|
|
|
|
|
|
|
#error OpenSSL version 0.9.7 or later is required. See comments in CA.pm |
262
|
|
|
|
|
|
|
#endif |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
static inline char* char0_value_or_null(SV* perlscalar) { |
265
|
|
|
|
|
|
|
STRLEN length; char* retval; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
SvPV(perlscalar, length); |
268
|
|
|
|
|
|
|
if (! SvPOK(perlscalar)) { return NULL; } |
269
|
|
|
|
|
|
|
SvGROW(perlscalar, length + 1); |
270
|
|
|
|
|
|
|
retval = SvPV_nolen(perlscalar); |
271
|
|
|
|
|
|
|
retval[length] = '\0'; |
272
|
|
|
|
|
|
|
return retval; |
273
|
|
|
|
|
|
|
} |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
static inline char* char0_value(SV* perlscalar) { |
276
|
|
|
|
|
|
|
char* retval = char0_value_or_null(perlscalar); |
277
|
|
|
|
|
|
|
return ( retval ? retval : "" ); |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
static inline SV* perl_wrap(const char* class, void* pointer) { |
281
|
|
|
|
|
|
|
SV* obj = sv_setref_pv(newSV(0), class, pointer); |
282
|
|
|
|
|
|
|
if (! obj) { croak("not enough memory"); } |
283
|
|
|
|
|
|
|
SvREADONLY_on(SvRV(obj)); |
284
|
|
|
|
|
|
|
return obj; |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
#define perl_unwrap(class, typename, obj) \ |
288
|
|
|
|
|
|
|
((typename) __perl_unwrap(__FILE__, __LINE__, (class), (obj))) |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
static inline void* __perl_unwrap(const char* file, int line, |
291
|
|
|
|
|
|
|
const char* class, SV* obj) { |
292
|
|
|
|
|
|
|
if (!(sv_isobject(obj) && sv_isa(obj, class))) { |
293
|
|
|
|
|
|
|
croak("%s:%d:perl_unwrap: got an invalid " |
294
|
|
|
|
|
|
|
"Perl argument (expected an object blessed " |
295
|
|
|
|
|
|
|
"in class ``%s'')", file, line, (class)); |
296
|
|
|
|
|
|
|
} |
297
|
|
|
|
|
|
|
return (void *)(intptr_t)SvIV(SvRV(obj)); |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
static inline SV* openssl_buf_to_SV(char* string, int length) { |
301
|
|
|
|
|
|
|
/* Note that a newmortal is not wanted here, even though |
302
|
|
|
|
|
|
|
* caller will typically return the SV* to Perl. This is because XS |
303
|
|
|
|
|
|
|
* performs some magic of its own for functions that return an SV (as |
304
|
|
|
|
|
|
|
* documented in L) |
305
|
|
|
|
|
|
|
* and Inline::C leverages that. */ |
306
|
|
|
|
|
|
|
SV* retval = newSVpv(string, length); |
307
|
|
|
|
|
|
|
OPENSSL_free(string); |
308
|
|
|
|
|
|
|
return retval; |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
static inline SV* openssl_string_to_SV(char* string) { |
312
|
|
|
|
|
|
|
return openssl_buf_to_SV(string, 0); |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
static inline SV* BIO_mem_to_SV(BIO *mem) { |
316
|
|
|
|
|
|
|
SV* retval; |
317
|
|
|
|
|
|
|
BUF_MEM* buf; |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
BIO_get_mem_ptr(mem, &buf); |
320
|
|
|
|
|
|
|
if (! buf) { |
321
|
|
|
|
|
|
|
BIO_free(mem); |
322
|
|
|
|
|
|
|
croak("BIO_get_mem_ptr failed"); |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
retval = newSVpv(buf->data, 0); |
325
|
|
|
|
|
|
|
if (! retval) { |
326
|
|
|
|
|
|
|
BIO_free(mem); |
327
|
|
|
|
|
|
|
croak("newSVpv failed"); |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
BIO_free(mem); |
330
|
|
|
|
|
|
|
return retval; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
#define ERRBUFSZ 512 |
334
|
|
|
|
|
|
|
#define THISPACKAGE "Crypt::OpenSSL::CA" |
335
|
|
|
|
|
|
|
static void sslcroak(char *fmt, ...) { |
336
|
|
|
|
|
|
|
va_list ap; /* The argument list hiding behind the |
337
|
|
|
|
|
|
|
hyphens in the protype above */ |
338
|
|
|
|
|
|
|
dSP; /* Required to be able to perform Perl |
339
|
|
|
|
|
|
|
callbacks */ |
340
|
|
|
|
|
|
|
char* argv[3]; /* The list of arguments to pass to the |
341
|
|
|
|
|
|
|
callback */ |
342
|
|
|
|
|
|
|
char croakbuf[ERRBUFSZ]; /* The buffer to typeset the main error |
343
|
|
|
|
|
|
|
message into */ |
344
|
|
|
|
|
|
|
char errbuf[ERRBUFSZ]; /* The buffer to typeset the auxillary error |
345
|
|
|
|
|
|
|
messages from OpenSSL into */ |
346
|
|
|
|
|
|
|
SV* dollar_at; /* Used to probe $@ to see if everything |
347
|
|
|
|
|
|
|
went well with the callback */ |
348
|
|
|
|
|
|
|
unsigned long sslerr; /* Will iterate through the OpenSSL |
349
|
|
|
|
|
|
|
error stack */ |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
va_start(ap, fmt); |
352
|
|
|
|
|
|
|
vsnprintf(croakbuf, ERRBUFSZ, fmt, ap); |
353
|
|
|
|
|
|
|
croakbuf[ERRBUFSZ - 1] = '\0'; |
354
|
|
|
|
|
|
|
va_end(ap); |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
argv[0] = "-message"; |
357
|
|
|
|
|
|
|
argv[1] = croakbuf; |
358
|
|
|
|
|
|
|
argv[2] = NULL; |
359
|
|
|
|
|
|
|
call_argv(THISPACKAGE "::_sslcroak_callback", G_DISCARD, argv); |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
argv[0] = "-openssl"; |
362
|
|
|
|
|
|
|
argv[1] = errbuf; |
363
|
|
|
|
|
|
|
while( (sslerr = ERR_get_error()) ) { |
364
|
|
|
|
|
|
|
ERR_error_string_n(sslerr, errbuf, ERRBUFSZ); |
365
|
|
|
|
|
|
|
errbuf[ERRBUFSZ - 1] = '\0'; |
366
|
|
|
|
|
|
|
call_argv(THISPACKAGE "::_sslcroak_callback", G_DISCARD, argv); |
367
|
|
|
|
|
|
|
} |
368
|
|
|
|
|
|
|
argv[0] = "DONE"; |
369
|
|
|
|
|
|
|
argv[1] = NULL; |
370
|
|
|
|
|
|
|
call_argv(THISPACKAGE "::_sslcroak_callback", G_DISCARD, argv); |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
dollar_at = get_sv("@", FALSE); |
373
|
|
|
|
|
|
|
if (dollar_at && sv_isobject(dollar_at)) { |
374
|
|
|
|
|
|
|
// Success! |
375
|
|
|
|
|
|
|
croak(Nullch); |
376
|
|
|
|
|
|
|
} else { |
377
|
|
|
|
|
|
|
// Something went bang, revert to the croakbuf. |
378
|
|
|
|
|
|
|
croak(croakbuf); |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
} |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
/* RFC3280, section 4.1.2.5 */ |
383
|
|
|
|
|
|
|
#define RFC3280_cutoff_date "20500000" "000000" |
384
|
|
|
|
|
|
|
static ASN1_TIME* parse_RFC3280_time(char* date, |
385
|
|
|
|
|
|
|
char** errmsg, char** sslerrmsg) { |
386
|
|
|
|
|
|
|
int status; |
387
|
|
|
|
|
|
|
int is_generalizedtime; |
388
|
|
|
|
|
|
|
ASN1_TIME* retval; |
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
if (strlen(date) != strlen(RFC3280_cutoff_date) + 1) { |
391
|
|
|
|
|
|
|
if (errmsg) { *errmsg = "Wrong date length"; } |
392
|
|
|
|
|
|
|
return NULL; |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
if (date[strlen(RFC3280_cutoff_date)] != 'Z') { |
395
|
|
|
|
|
|
|
if (errmsg) { *errmsg = "Wrong date format"; } |
396
|
|
|
|
|
|
|
return NULL; |
397
|
|
|
|
|
|
|
} |
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
if (! (retval = ASN1_TIME_new())) { |
400
|
|
|
|
|
|
|
if (errmsg) { *errmsg = "ASN1_TIME_new failed"; } |
401
|
|
|
|
|
|
|
return NULL; |
402
|
|
|
|
|
|
|
} |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
is_generalizedtime = (strcmp(date, RFC3280_cutoff_date) > 0); |
405
|
|
|
|
|
|
|
if (! (is_generalizedtime ? |
406
|
|
|
|
|
|
|
ASN1_GENERALIZEDTIME_set_string(retval, date) : |
407
|
|
|
|
|
|
|
ASN1_UTCTIME_set_string(retval, date + 2)) ) { |
408
|
|
|
|
|
|
|
ASN1_TIME_free(retval); |
409
|
|
|
|
|
|
|
if (errmsg) { |
410
|
|
|
|
|
|
|
*errmsg = (is_generalizedtime ? |
411
|
|
|
|
|
|
|
"ASN1_GENERALIZEDTIME_set_string failed (bad date format?)" : |
412
|
|
|
|
|
|
|
"ASN1_UTCTIME_set_string failed (bad date format?)"); |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
return NULL; |
415
|
|
|
|
|
|
|
} |
416
|
|
|
|
|
|
|
return retval; |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
static ASN1_TIME* parse_RFC3280_time_or_croak(char* date) { |
420
|
|
|
|
|
|
|
char* plainerr = NULL; char* sslerr = NULL; |
421
|
|
|
|
|
|
|
ASN1_INTEGER* retval = NULL; |
422
|
|
|
|
|
|
|
if ((retval = parse_RFC3280_time(date, &plainerr, &sslerr))) { |
423
|
|
|
|
|
|
|
return retval; |
424
|
|
|
|
|
|
|
} |
425
|
|
|
|
|
|
|
if (plainerr) { croak(plainerr); } |
426
|
|
|
|
|
|
|
if (sslerr) { sslcroak(sslerr); } |
427
|
|
|
|
|
|
|
croak("Unknown error in parse_RFC3280_time"); |
428
|
|
|
|
|
|
|
return NULL; /* Not reached */ |
429
|
|
|
|
|
|
|
} |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
static ASN1_INTEGER* parse_serial(char* hexserial, |
432
|
|
|
|
|
|
|
char** errmsg, char** sslerrmsg) { |
433
|
|
|
|
|
|
|
BIGNUM* serial = NULL; |
434
|
|
|
|
|
|
|
ASN1_INTEGER* retval; |
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
if (! (hexserial[0] == '0' && hexserial[1] == 'x')) { |
437
|
|
|
|
|
|
|
if (errmsg) { |
438
|
|
|
|
|
|
|
*errmsg = "Bad serial string, should start with 0x"; |
439
|
|
|
|
|
|
|
} |
440
|
|
|
|
|
|
|
return NULL; |
441
|
|
|
|
|
|
|
} |
442
|
|
|
|
|
|
|
if (! BN_hex2bn(&serial, hexserial + 2)) { |
443
|
|
|
|
|
|
|
if (sslerrmsg) { *sslerrmsg = "BN_hex2bn failed"; } |
444
|
|
|
|
|
|
|
return NULL; |
445
|
|
|
|
|
|
|
} |
446
|
|
|
|
|
|
|
retval = BN_to_ASN1_INTEGER(serial, NULL); |
447
|
|
|
|
|
|
|
BN_free(serial); |
448
|
|
|
|
|
|
|
if (! retval) { |
449
|
|
|
|
|
|
|
if (sslerrmsg) { *sslerrmsg = "BN_to_ASN1_INTEGER failed"; } |
450
|
|
|
|
|
|
|
return NULL; |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
return retval; |
453
|
|
|
|
|
|
|
} |
454
|
|
|
|
|
|
|
|
455
|
|
|
|
|
|
|
static ASN1_INTEGER* parse_serial_or_croak(char* hexserial) { |
456
|
|
|
|
|
|
|
char* plainerr = NULL; char* sslerr = NULL; |
457
|
|
|
|
|
|
|
ASN1_INTEGER* retval = NULL; |
458
|
|
|
|
|
|
|
if ((retval = parse_serial(hexserial, &plainerr, &sslerr))) { |
459
|
|
|
|
|
|
|
return retval; |
460
|
|
|
|
|
|
|
} |
461
|
|
|
|
|
|
|
if (plainerr) { croak(plainerr); } |
462
|
|
|
|
|
|
|
if (sslerr) { sslcroak(sslerr); } |
463
|
|
|
|
|
|
|
croak("Unknown error in parse_serial"); |
464
|
|
|
|
|
|
|
return NULL; /* Not reached */ |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
C_BOILERPLATE |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=head2 BOOT-time effect |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
Each C<.so> XS module will be fitted with a C section (see |
472
|
|
|
|
|
|
|
L which automatically gets executed upon loading it |
473
|
|
|
|
|
|
|
with L or L. The C section is the same for |
474
|
|
|
|
|
|
|
all subpackages in L; it ensures that various |
475
|
|
|
|
|
|
|
stuff is loaded inside OpenSSL, such as C, |
476
|
|
|
|
|
|
|
C and all that jazz. After the boot |
477
|
|
|
|
|
|
|
code completes, C<$Crypt::OpenSSL::CA::openssl_stuff_loaded> will be |
478
|
|
|
|
|
|
|
1, so that the following XS modules can skip that when they in turn |
479
|
|
|
|
|
|
|
get loaded. |
480
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
=cut |
482
|
|
|
|
|
|
|
|
483
|
0
|
|
|
0
|
|
|
sub _c_boot_section { <<"ENSURE_OPENSSL_STUFF_LOADED" } |
484
|
|
|
|
|
|
|
SV* already_loaded = get_sv |
485
|
|
|
|
|
|
|
("Crypt::OpenSSL::CA::openssl_stuff_loaded", 1); |
486
|
|
|
|
|
|
|
if (SvOK(already_loaded)) { return; } |
487
|
|
|
|
|
|
|
sv_setiv(already_loaded, 1); |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
ERR_load_crypto_strings(); |
490
|
|
|
|
|
|
|
OpenSSL_add_all_algorithms(); |
491
|
|
|
|
|
|
|
ENSURE_OPENSSL_STUFF_LOADED |
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head1 INTERNALS |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
The C<< use Crypt::OpenSSL::CA::Inline::C >> idiom described in |
496
|
|
|
|
|
|
|
L is implemented in terms of L. |
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
=head3 %c_code |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
A lexical variable that L uses to accumulate all the C code |
501
|
|
|
|
|
|
|
submitted by L. Keys are package names, and |
502
|
|
|
|
|
|
|
values are snippets of C. |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=cut |
505
|
|
|
|
|
|
|
|
506
|
1
|
|
|
|
|
26
|
my %c_code; |
507
|
|
|
|
|
|
|
|
508
|
1
|
|
|
1
|
|
1213
|
use Inline::C (); |
|
1
|
|
|
|
|
72088
|
|
|
1
|
|
|
|
|
2642
|
|
509
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
=head3 import () |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
Called whenever one of the C<< use Crypt::OpenSSL::CA::Inline::C "foo" |
513
|
|
|
|
|
|
|
>> pragmas (listed in L) is seen by Perl; performs the |
514
|
|
|
|
|
|
|
actual magic of the module. Stashes everything into L%c_code>, and |
515
|
|
|
|
|
|
|
invokes L at the end. |
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
=cut |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
sub import { |
520
|
0
|
|
|
0
|
|
|
my ($class, $c_code) = @_; |
521
|
|
|
|
|
|
|
|
522
|
0
|
0
|
|
|
|
|
return if ! defined $c_code; # A simple "use" |
523
|
|
|
|
|
|
|
|
524
|
0
|
0
|
|
|
|
|
return $class->compile_everything if ($c_code eq "__END__"); |
525
|
|
|
|
|
|
|
|
526
|
0
|
|
|
|
|
|
my ($package, $file, $line) = caller; |
527
|
0
|
|
|
|
|
|
$c_code{$package} .= sprintf(qq'#line %d "%s"\n', $line + 1, $file) |
528
|
|
|
|
|
|
|
. $c_code; |
529
|
0
|
|
|
|
|
|
return; |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
|
532
|
|
|
|
|
|
|
=head3 compile_everything () |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
Called when L is seen. Invokes |
535
|
|
|
|
|
|
|
L once for every package (that is, every key in |
536
|
|
|
|
|
|
|
L%c_code>), prepending L<_c_boilerplate> each time. |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
=cut |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
sub compile_everything { |
541
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
542
|
0
|
|
|
|
|
|
foreach my $package (keys %c_code) { |
543
|
0
|
|
|
|
|
|
$class->compile_into($package, _c_boilerplate . $c_code{$package}, |
544
|
|
|
|
|
|
|
-boot_section => _c_boot_section()); |
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
} |
547
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=head3 compile_into ($package, $c_code, %named_options) |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
Compile $c_code and make its functions available as part of $package's |
551
|
|
|
|
|
|
|
namespace, courtesy to L magic. Works by invoking |
552
|
|
|
|
|
|
|
L in a tweaked fashion, so as to compile with all |
553
|
|
|
|
|
|
|
warnings turned into errors (i.e. C<-Wall -Werror>) and to link with |
554
|
|
|
|
|
|
|
the OpenSSL libraries. The environment variables are taken into |
555
|
|
|
|
|
|
|
account (see L). |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
Available named options are: |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
=over |
560
|
|
|
|
|
|
|
|
561
|
|
|
|
|
|
|
=item B<< -boot_section => $c_code >> |
562
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
Adds $c_code to the BOOT section of the generated .so module. |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=back |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
=cut |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
sub compile_into { |
570
|
0
|
|
|
0
|
0
|
|
my ($class, $package, $c_code, %opts) = @_; |
571
|
0
|
0
|
|
|
|
|
my $compile_params = ($class->full_debugging ? |
572
|
|
|
|
|
|
|
<<'COMPILE_PARAMS_DEBUG' : |
573
|
|
|
|
|
|
|
CCFLAGS => "-Wall -Wno-unused -Werror -save-temps", |
574
|
|
|
|
|
|
|
OPTIMIZE => "-g", |
575
|
|
|
|
|
|
|
CLEAN_AFTER_BUILD => 0, |
576
|
|
|
|
|
|
|
COMPILE_PARAMS_DEBUG |
577
|
|
|
|
|
|
|
<<'COMPILE_PARAMS_OPTIMIZED'); |
578
|
|
|
|
|
|
|
OPTIMIZE => "-g -O2", |
579
|
|
|
|
|
|
|
COMPILE_PARAMS_OPTIMIZED |
580
|
|
|
|
|
|
|
|
581
|
0
|
|
0
|
|
|
|
my $openssl_params = sprintf('LIBS => "%s -lcrypto -lssl",', |
582
|
|
|
|
|
|
|
($ENV{BUILD_OPENSSL_LDFLAGS} or "")); |
583
|
0
|
0
|
|
|
|
|
if ($ENV{BUILD_OPENSSL_CFLAGS}) { |
584
|
0
|
|
|
|
|
|
$openssl_params .= qq' INC => "$ENV{BUILD_OPENSSL_CFLAGS}",'; |
585
|
|
|
|
|
|
|
} |
586
|
|
|
|
|
|
|
|
587
|
0
|
0
|
|
|
|
|
my $version_params = |
588
|
|
|
|
|
|
|
( $Crypt::OpenSSL::CA::VERSION ? |
589
|
|
|
|
|
|
|
qq'VERSION => "$Crypt::OpenSSL::CA::VERSION",' : "" ); |
590
|
|
|
|
|
|
|
|
591
|
0
|
0
|
|
|
|
|
my $boot_params = ($opts{-boot_section} ? <<"BOOT_CONFIG" : ""); |
592
|
|
|
|
|
|
|
BOOT => <<'BOOT_SECTION', |
593
|
|
|
|
|
|
|
$opts{-boot_section} |
594
|
|
|
|
|
|
|
BOOT_SECTION |
595
|
|
|
|
|
|
|
BOOT_CONFIG |
596
|
|
|
|
|
|
|
|
597
|
0
|
0
|
|
|
|
|
eval <<"FAKE_Inline_C_INVOCATION"; die $@ if $@; |
|
0
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
package $package; |
599
|
|
|
|
|
|
|
use Inline C => Config => |
600
|
|
|
|
|
|
|
NAME => '$package', |
601
|
|
|
|
|
|
|
$compile_params |
602
|
|
|
|
|
|
|
$version_params |
603
|
|
|
|
|
|
|
$openssl_params |
604
|
|
|
|
|
|
|
$boot_params |
605
|
|
|
|
|
|
|
; |
606
|
|
|
|
|
|
|
use Inline C => <<'C_CODE'; |
607
|
|
|
|
|
|
|
$c_code |
608
|
|
|
|
|
|
|
C_CODE |
609
|
|
|
|
|
|
|
FAKE_Inline_C_INVOCATION |
610
|
|
|
|
|
|
|
|
611
|
0
|
|
|
|
|
|
return 1; |
612
|
|
|
|
|
|
|
} |
613
|
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
=head3 full_debugging |
615
|
|
|
|
|
|
|
|
616
|
|
|
|
|
|
|
Returns true iff the environment variable L is set. |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
=cut |
619
|
|
|
|
|
|
|
|
620
|
0
|
|
|
0
|
0
|
|
sub full_debugging { ! ! $ENV{FULL_DEBUGGING} } |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
=head3 installed_version |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
Returns what the source code of this module will look like (with POD |
625
|
|
|
|
|
|
|
and everything) after it is installed. The installed version is a dud |
626
|
|
|
|
|
|
|
stub; its L method only loads the XS DLL, and it is no longer |
627
|
|
|
|
|
|
|
possible to alter the C code once the module has been installed. The |
628
|
|
|
|
|
|
|
upside is that in thanks to that, L is a dependency only at |
629
|
|
|
|
|
|
|
compile time. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
=begin this_pod_is_not_ours |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
=cut |
634
|
|
|
|
|
|
|
|
635
|
0
|
|
|
0
|
0
|
|
sub installed_version { <<'INSTALLED_VERSION' } |
636
|
|
|
|
|
|
|
#!perl -w |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
package Crypt::OpenSSL::CA::Inline::C; |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
use strict; |
641
|
|
|
|
|
|
|
use XSLoader; |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
sub import { |
644
|
|
|
|
|
|
|
my ($class, $stuff) = @_; |
645
|
|
|
|
|
|
|
return if ! defined $stuff; |
646
|
|
|
|
|
|
|
return if $stuff eq "__END__"; |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
my ($package) = caller; |
649
|
|
|
|
|
|
|
no strict "refs"; |
650
|
|
|
|
|
|
|
push @{$package."::ISA"}, qw(XSLoader); |
651
|
|
|
|
|
|
|
XSLoader::load($package); |
652
|
|
|
|
|
|
|
} |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
=head1 NAME |
655
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
Crypt::OpenSSL::CA::Inline::C - The Inline magic (or lack thereof) for |
657
|
|
|
|
|
|
|
Crypt::OpenSSL::CA |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
=head1 SYNOPSIS |
660
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
use Crypt::OpenSSL::CA::Inline::C $and_the_rest_is_ignored; |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
# ... |
664
|
|
|
|
|
|
|
|
665
|
|
|
|
|
|
|
use Crypt::OpenSSL::CA::Inline::C "__END__"; |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
=head1 DESCRIPTION |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
This package simply loads the DLLs that contain the parts of |
670
|
|
|
|
|
|
|
L that are made of XS code. It is a stubbed-down |
671
|
|
|
|
|
|
|
version of the full-fledged I that |
672
|
|
|
|
|
|
|
replaces the real thing at module install time. |
673
|
|
|
|
|
|
|
|
674
|
|
|
|
|
|
|
There is more to I, such as the ability |
675
|
|
|
|
|
|
|
to dynamically modify and recompile the C code snippets in |
676
|
|
|
|
|
|
|
I's code source. But in order to grasp hold of its |
677
|
|
|
|
|
|
|
power, you have to use the full source code tarball and not just the |
678
|
|
|
|
|
|
|
installed version. |
679
|
|
|
|
|
|
|
|
680
|
|
|
|
|
|
|
=cut |
681
|
|
|
|
|
|
|
|
682
|
|
|
|
|
|
|
1; |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
INSTALLED_VERSION |
685
|
|
|
|
|
|
|
|
686
|
|
|
|
|
|
|
=end this_pod_is_not_ours |
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
=head1 ENVIRONMENT VARIABLES |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
=head2 FULL_DEBUGGING |
691
|
|
|
|
|
|
|
|
692
|
|
|
|
|
|
|
Setting this variable to 1 causes the C code to be compiled without |
693
|
|
|
|
|
|
|
optimization, allowing gdb to dump symbols of static functions with |
694
|
|
|
|
|
|
|
only one call site (which comprises most of the C code in |
695
|
|
|
|
|
|
|
L). Also, the temporary build files are left |
696
|
|
|
|
|
|
|
intact if C is set. |
697
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
Developpers, please note that in the absence of C, the |
699
|
|
|
|
|
|
|
default compiler flags are C<-g -O2>, still allowing for a range of |
700
|
|
|
|
|
|
|
debugging strategies. C should therefore only be set |
701
|
|
|
|
|
|
|
on a one-shot basis by developpers who have a specific need for it. |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
=head2 BUILD_OPENSSL_CFLAGS |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
Contains the CFLAGS to pass so as to compile C code that links against |
706
|
|
|
|
|
|
|
OpenSSL; eg C<< -I/usr/lib/openssl/include >> or something. Passed on |
707
|
|
|
|
|
|
|
to L by L. |
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
=head2 BUILD_OPENSSL_LDFLAGS |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
Contains the LDFLAGS to pass so as to link with the OpenSSL libraries; |
712
|
|
|
|
|
|
|
eg C<< -L/usr/lib/openssl/lib >> or something. Passed on to |
713
|
|
|
|
|
|
|
L by L. |
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
=head1 SEE ALSO |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
L, L, L, L. |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
=cut |
720
|
|
|
|
|
|
|
|
721
|
1
|
50
|
|
|
|
2980
|
require My::Tests::Below unless caller(); |
722
|
|
|
|
|
|
|
|
723
|
0
|
|
|
|
|
0
|
1; |
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
__END__ |