summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_cert.c
diff options
context:
space:
mode:
authorNils Larsch <nils@openssl.org>2005-06-01 10:38:44 +0200
committerNils Larsch <nils@openssl.org>2005-06-01 10:38:44 +0200
commit1d42741a19d31b50b645a6024909e45e9501fb65 (patch)
treeae558a9bf6b812bccfdc798a5338c5249b0de507 /ssl/ssl_cert.c
parentfix assertion (diff)
downloadopenssl-1d42741a19d31b50b645a6024909e45e9501fb65.tar.xz
openssl-1d42741a19d31b50b645a6024909e45e9501fb65.zip
clear error queue on success and return NULL if no cert could be read
PR: 1088
Diffstat (limited to 'ssl/ssl_cert.c')
-rw-r--r--ssl/ssl_cert.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index 93d2b13791..0c9bd07378 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -635,14 +635,13 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
BIO *in;
X509 *x=NULL;
X509_NAME *xn=NULL;
- STACK_OF(X509_NAME) *ret,*sk;
+ STACK_OF(X509_NAME) *ret = NULL,*sk;
- ret=sk_X509_NAME_new_null();
sk=sk_X509_NAME_new(xname_cmp);
in=BIO_new(BIO_s_file_internal());
- if ((ret == NULL) || (sk == NULL) || (in == NULL))
+ if ((sk == NULL) || (in == NULL))
{
SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE,ERR_R_MALLOC_FAILURE);
goto err;
@@ -655,6 +654,15 @@ STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)
{
if (PEM_read_bio_X509(in,&x,NULL,NULL) == NULL)
break;
+ if (ret == NULL)
+ {
+ ret = sk_X509_NAME_new_null();
+ if (ret == NULL)
+ {
+ SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE,ERR_R_MALLOC_FAILURE);
+ goto err;
+ }
+ }
if ((xn=X509_get_subject_name(x)) == NULL) goto err;
/* check for duplicates */
xn=X509_NAME_dup(xn);
@@ -677,6 +685,8 @@ err:
if (sk != NULL) sk_X509_NAME_free(sk);
if (in != NULL) BIO_free(in);
if (x != NULL) X509_free(x);
+ if (ret != NULL)
+ ERR_clear_error();
return(ret);
}
#endif