@@ -517,7 +517,9 @@ static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
517
517
518
518
/*
519
519
* call-seq:
520
- * StoreContext.new(store, cert = nil, chain = nil)
520
+ * StoreContext.new(store, cert = nil, untrusted = nil)
521
+ *
522
+ * Sets up a StoreContext for a verification of the X.509 certificate _cert_.
521
523
*/
522
524
static VALUE
523
525
ossl_x509stctx_initialize (int argc , VALUE * argv , VALUE self )
@@ -527,15 +529,24 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
527
529
X509_STORE * x509st ;
528
530
X509 * x509 = NULL ;
529
531
STACK_OF (X509 ) * x509s = NULL ;
532
+ int state ;
530
533
531
534
rb_scan_args (argc , argv , "12" , & store , & cert , & chain );
532
535
GetX509StCtx (self , ctx );
533
536
GetX509Store (store , x509st );
534
- if (!NIL_P (cert )) x509 = DupX509CertPtr (cert ); /* NEED TO DUP */
535
- if (!NIL_P (chain )) x509s = ossl_x509_ary2sk (chain );
536
- if (X509_STORE_CTX_init (ctx , x509st , x509 , x509s ) != 1 ){
537
+ if (!NIL_P (cert ))
538
+ x509 = DupX509CertPtr (cert ); /* NEED TO DUP */
539
+ if (!NIL_P (chain )) {
540
+ x509s = ossl_protect_x509_ary2sk (chain , & state );
541
+ if (state ) {
542
+ X509_free (x509 );
543
+ rb_jump_tag (state );
544
+ }
545
+ }
546
+ if (X509_STORE_CTX_init (ctx , x509st , x509 , x509s ) != 1 ){
547
+ X509_free (x509 );
537
548
sk_X509_pop_free (x509s , X509_free );
538
- ossl_raise (eX509StoreError , NULL );
549
+ ossl_raise (eX509StoreError , "X509_STORE_CTX_init" );
539
550
}
540
551
if (!NIL_P (t = rb_iv_get (store , "@time" )))
541
552
ossl_x509stctx_set_time (self , t );
0 commit comments