@@ -276,6 +276,8 @@ SV * new(class, ...)
276
276
if (ST (1 ) != NULL )
277
277
// TODO: ensure_string_sv
278
278
CAfile = ST (1 );
279
+ if (strlen (SvPV_nolen (CAfile )) == 0 )
280
+ CAfile = NULL ;
279
281
280
282
if (items > 2 )
281
283
options = ensure_hv (ST (2 ), "options" );
@@ -318,46 +320,39 @@ SV * new(class, ...)
318
320
if (!strict_certs )
319
321
X509_STORE_set_verify_cb_func (x509_store , cb1 );
320
322
321
- if (noCAfile ) {
322
- X509_LOOKUP_init (cafile_lookup );
323
- }
324
- else {
323
+ if (CAfile != NULL || !noCAfile ) {
325
324
cafile_lookup = X509_STORE_add_lookup (x509_store , X509_LOOKUP_file ());
326
- }
327
-
328
- if (cafile_lookup == NULL ) {
329
- X509_STORE_free (x509_store );
330
- croak ("failure to add lookup to store: %s" , ssl_error ());
331
- }
332
-
333
- if (CAfile != NULL ) {
334
- if (!X509_STORE_load_locations (x509_store , SvPV_nolen (CAfile ), NULL )) {
325
+ if (cafile_lookup == NULL ) {
335
326
X509_STORE_free (x509_store );
336
- croak ("Error loading file %s: %s\n" , SvPV_nolen (CAfile ),
337
- ssl_error ());
327
+ croak ("failure to add lookup to store: %s" , ssl_error ());
328
+ }
329
+ if (CAfile != NULL ) {
330
+ if (!X509_LOOKUP_load_file (cafile_lookup , SvPV_nolen (CAfile ), X509_FILETYPE_PEM )) {
331
+ X509_STORE_free (x509_store );
332
+ croak ("Error loading file %s: %s\n" , SvPV_nolen (CAfile ),
333
+ ssl_error ());
334
+ }
335
+ } else {
336
+ X509_LOOKUP_load_file (cafile_lookup , NULL , X509_FILETYPE_DEFAULT );
338
337
}
339
338
}
340
339
341
- if (noCApath ) {
342
- X509_LOOKUP_init (cadir_lookup );
343
- }
344
- else {
340
+ if (CApath != NULL || !noCApath ) {
345
341
cadir_lookup = X509_STORE_add_lookup (x509_store , X509_LOOKUP_hash_dir ());
346
- }
347
-
348
- if (cadir_lookup == NULL ) {
349
- X509_STORE_free (x509_store );
350
- croak ("failure to add lookup to store: %s" , ssl_error ());
351
- }
352
-
353
- if (CApath != NULL ) {
354
- if (!X509_LOOKUP_add_dir (cadir_lookup , SvPV_nolen (CApath ), X509_FILETYPE_PEM )) {
342
+ if (cadir_lookup == NULL ) {
355
343
X509_STORE_free (x509_store );
356
- croak ("Error loading directory %s\n" , SvPV_nolen (CApath ));
344
+ croak ("failure to add lookup to store: %s" , ssl_error ());
345
+ }
346
+ if (CApath != NULL ) {
347
+ if (!X509_LOOKUP_add_dir (cadir_lookup , SvPV_nolen (CApath ), X509_FILETYPE_PEM )) {
348
+ X509_STORE_free (x509_store );
349
+ croak ("Error loading directory %s\n" , SvPV_nolen (CApath ));
350
+ }
351
+ } else {
352
+ X509_LOOKUP_add_dir (cadir_lookup , NULL , X509_FILETYPE_DEFAULT );
357
353
}
358
354
}
359
355
360
-
361
356
HV * attributes = newHV ();
362
357
363
358
SV * const self = newRV_noinc ( (SV * )attributes );
0 commit comments