Skip to content

Commit 257f68b

Browse files
committed
Fix a bug in the client certificate loading logic. It was hidden from
view because the error that should have been reported gets thrown away when the error callback was not defined. * buckets/ssl_buckets.c (ssl_need_client_cert): Add a rather caustic FIXME that the function should be split in two. Use OSSL_STORE_open() instead of the _ex() variant because we don't use any of the extended parameters. When iterating over a certificate store's contents, check the EOF condition only after attempting to read the next item. git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1931046 13f79535-47bb-0310-9956-ffa450edef68
1 parent b63c1bb commit 257f68b

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

buckets/ssl_buckets.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,10 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
16281628
}
16291629

16301630
#if defined(SERF_HAVE_OSSL_STORE_OPEN_EX)
1631+
/* FIXME: This is completely messed up. Extract the OPENSSL_STORE
1632+
part into a separate function instead of using break
1633+
+ ERR_peek_error() for something that, for lack of a more
1634+
friendly term, might be called "error handling". */
16311635

16321636
/* until further notice */
16331637
*cert = NULL;
@@ -1669,8 +1673,7 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
16691673
/* server side request some certs? this list may be empty */
16701674
requested = SSL_get_client_CA_list(ssl);
16711675

1672-
store = OSSL_STORE_open_ex(cert_uri, NULL, NULL, ui_method, ctx, NULL,
1673-
NULL, NULL);
1676+
store = OSSL_STORE_open(cert_uri, ui_method, ctx, NULL, NULL);
16741677
if (!store) {
16751678

16761679
if (ctx->error_callback) {
@@ -1685,8 +1688,13 @@ static int ssl_need_client_cert(SSL *ssl, X509 **cert, EVP_PKEY **pkey)
16851688

16861689
/* walk the store, what are we working with */
16871690

1688-
while (!OSSL_STORE_eof(store)) {
1691+
for (;;) {
16891692
info = OSSL_STORE_load(store);
1693+
if (OSSL_STORE_eof(store)) {
1694+
/* NOTE: OSSL_STORE_eof() is not signalled until *after* the
1695+
first OSSL_STORE_load() fails. */
1696+
break;
1697+
}
16901698

16911699
if (!info) {
16921700

0 commit comments

Comments
 (0)