You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@serf.apache.org by br...@apache.org on 2026/01/01 17:33:49 UTC

svn commit: r1931046 - serf/trunk/buckets

Author: brane
Date: Thu Jan  1 17:33:48 2026
New Revision: 1931046

Log:
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.

Modified:
   serf/trunk/buckets/ssl_buckets.c

Modified: serf/trunk/buckets/ssl_buckets.c
==============================================================================
--- serf/trunk/buckets/ssl_buckets.c	Thu Jan  1 15:08:48 2026	(r1931045)
+++ serf/trunk/buckets/ssl_buckets.c	Thu Jan  1 17:33:48 2026	(r1931046)
@@ -1628,6 +1628,10 @@ static int ssl_need_client_cert(SSL *ssl
     }
 
 #if defined(SERF_HAVE_OSSL_STORE_OPEN_EX)
+    /* FIXME: This is completely messed up. Extract the OPENSSL_STORE
+              part into a separate function instead of using break
+              + ERR_peek_error() for something that, for lack of a more
+              friendly term, might be called "error handling". */
 
     /* until further notice */
     *cert = NULL;
@@ -1669,8 +1673,7 @@ static int ssl_need_client_cert(SSL *ssl
         /* server side request some certs? this list may be empty */
         requested = SSL_get_client_CA_list(ssl);
 
-        store = OSSL_STORE_open_ex(cert_uri, NULL, NULL, ui_method, ctx, NULL,
-                                   NULL, NULL);
+        store = OSSL_STORE_open(cert_uri, ui_method, ctx, NULL, NULL);
         if (!store) {
 
             if (ctx->error_callback) {
@@ -1685,8 +1688,13 @@ static int ssl_need_client_cert(SSL *ssl
 
         /* walk the store, what are we working with */
 
-        while (!OSSL_STORE_eof(store)) {
+        for (;;) {
             info = OSSL_STORE_load(store);
+            if (OSSL_STORE_eof(store)) {
+                /* NOTE: OSSL_STORE_eof() is not signalled until *after* the
+                         first OSSL_STORE_load() fails. */
+                break;
+            }
 
             if (!info) {
 


Re: svn commit: r1931046 - serf/trunk/buckets

Posted by Branko Čibej <br...@apache.org>.
On 2. 1. 26 14:04, Daniel Sahlberg wrote:
> Den tors 1 jan. 2026 kl 18:33 skrev<br...@apache.org>:
>
>> Author: brane
>> Date: Thu Jan  1 17:33:48 2026
>> New Revision: 1931046
>>
>>
> ...
>
>
>>     Use OSSL_STORE_open() instead of the _ex() variant because we don't
>>     use any of the extended parameters.
>>
> ...
>
>
>>   #if defined(SERF_HAVE_OSSL_STORE_OPEN_EX)
>>
> ...
>
>
>> -        store = OSSL_STORE_open_ex(cert_uri, NULL, NULL, ui_method, ctx,
>> NULL,
>> -                                   NULL, NULL);
>> +        store = OSSL_STORE_open(cert_uri, ui_method, ctx, NULL, NULL);
>>
> Does it make sense to also re-name the define (and obviously also change
> the feature detection in SConstruct/CMakeList.txt)? As far as I can tell,
> the other functions that are used protected by this #ifdef should be
> available whenever OSSL_STORE_open is available.

If OSSL_STORE_open_ex() is available, then OSSL_STORE_open() is, as 
well, as well as the related structures. I looked at changing the check, 
but I think that at most we could change the symbol name.


> In practice this means we would support the OSSL_STORE functions even with
> OpenSSL 1.1 (OSSL_STORE_open_ex appeared in 3.0). On the other hand, nobody
> should be using such an old version anyway...

We could just use the OPENSSL_VERSION_PREREQ() macro. I think it's 
better to restrict the use of this feature to OpenSSL 3+, so looking for 
OSSL_STORE_open_ex() even if we don't use it is OK.


-- Brane

Re: svn commit: r1931046 - serf/trunk/buckets

Posted by Daniel Sahlberg <da...@gmail.com>.
Den tors 1 jan. 2026 kl 18:33 skrev <br...@apache.org>:

> Author: brane
> Date: Thu Jan  1 17:33:48 2026
> New Revision: 1931046
>
>
...


>    Use OSSL_STORE_open() instead of the _ex() variant because we don't
>    use any of the extended parameters.
>

...


>  #if defined(SERF_HAVE_OSSL_STORE_OPEN_EX)
>

...


> -        store = OSSL_STORE_open_ex(cert_uri, NULL, NULL, ui_method, ctx,
> NULL,
> -                                   NULL, NULL);
> +        store = OSSL_STORE_open(cert_uri, ui_method, ctx, NULL, NULL);
>

Does it make sense to also re-name the define (and obviously also change
the feature detection in SConstruct/CMakeList.txt)? As far as I can tell,
the other functions that are used protected by this #ifdef should be
available whenever OSSL_STORE_open is available.

In practice this means we would support the OSSL_STORE functions even with
OpenSSL 1.1 (OSSL_STORE_open_ex appeared in 3.0). On the other hand, nobody
should be using such an old version anyway...

Cheers,
Daniel