Skip to content

Commit b31809b

Browse files
committed
x509store: avoid ossl_raise() calls with NULL message
Use the OpenSSL function name that caused the error to generate a better error message.
1 parent fa1da69 commit b31809b

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

ext/openssl/ossl_x509store.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,8 @@ ossl_x509store_alloc(VALUE klass)
157157
VALUE obj;
158158

159159
obj = NewX509Store(klass);
160-
if((store = X509_STORE_new()) == NULL){
161-
ossl_raise(eX509StoreError, NULL);
162-
}
160+
if ((store = X509_STORE_new()) == NULL)
161+
ossl_raise(eX509StoreError, "X509_STORE_new");
163162
SetX509Store(obj, store);
164163

165164
return obj;
@@ -365,9 +364,8 @@ ossl_x509store_set_default_paths(VALUE self)
365364
X509_STORE *store;
366365

367366
GetX509Store(self, store);
368-
if (X509_STORE_set_default_paths(store) != 1){
369-
ossl_raise(eX509StoreError, NULL);
370-
}
367+
if (X509_STORE_set_default_paths(store) != 1)
368+
ossl_raise(eX509StoreError, "X509_STORE_set_default_paths");
371369

372370
return Qnil;
373371
}
@@ -386,9 +384,8 @@ ossl_x509store_add_cert(VALUE self, VALUE arg)
386384

387385
cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
388386
GetX509Store(self, store);
389-
if (X509_STORE_add_cert(store, cert) != 1){
390-
ossl_raise(eX509StoreError, NULL);
391-
}
387+
if (X509_STORE_add_cert(store, cert) != 1)
388+
ossl_raise(eX509StoreError, "X509_STORE_add_cert");
392389

393390
return self;
394391
}
@@ -407,9 +404,8 @@ ossl_x509store_add_crl(VALUE self, VALUE arg)
407404

408405
crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
409406
GetX509Store(self, store);
410-
if (X509_STORE_add_crl(store, crl) != 1){
411-
ossl_raise(eX509StoreError, NULL);
412-
}
407+
if (X509_STORE_add_crl(store, crl) != 1)
408+
ossl_raise(eX509StoreError, "X509_STORE_add_crl");
413409

414410
return self;
415411
}
@@ -488,9 +484,8 @@ ossl_x509stctx_alloc(VALUE klass)
488484
VALUE obj;
489485

490486
obj = NewX509StCtx(klass);
491-
if((ctx = X509_STORE_CTX_new()) == NULL){
492-
ossl_raise(eX509StoreError, NULL);
493-
}
487+
if ((ctx = X509_STORE_CTX_new()) == NULL)
488+
ossl_raise(eX509StoreError, "X509_STORE_CTX_new");
494489
SetX509StCtx(obj, ctx);
495490

496491
return obj;
@@ -557,12 +552,12 @@ ossl_x509stctx_verify(VALUE self)
557552

558553
switch (X509_verify_cert(ctx)) {
559554
case 1:
560-
return Qtrue;
555+
return Qtrue;
561556
case 0:
562-
ossl_clear_error();
563-
return Qfalse;
557+
ossl_clear_error();
558+
return Qfalse;
564559
default:
565-
ossl_raise(eX509CertError, NULL);
560+
ossl_raise(eX509CertError, "X509_verify_cert");
566561
}
567562
}
568563

0 commit comments

Comments
 (0)