]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream, global: Rename ssl_iostream_has_[valid_]client_cert() to ssl_iostre...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 8 Aug 2025 12:30:58 +0000 (15:30 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 11 Aug 2025 07:47:35 +0000 (07:47 +0000)
These functions can be used (and are used) for both client and server
connections, so it's confusing having the "client" in the function name.

src/lib-ssl-iostream/iostream-openssl.c
src/lib-ssl-iostream/iostream-ssl.c
src/lib-ssl-iostream/iostream-ssl.h
src/login-common/client-common.c
src/login-common/sasl-server.c

index 6122731072dff3f6665d8457c305e65ba565e27d..c0da08388ee46f037ca701bf7791e546b7dd4603 100644 (file)
@@ -577,7 +577,7 @@ static bool
 openssl_iostream_cert_match_name(struct ssl_iostream *ssl_io,
                                 const char *verify_name, const char **reason_r)
 {
-       if (!ssl_iostream_has_valid_client_cert(ssl_io)) {
+       if (!ssl_iostream_has_valid_cert(ssl_io)) {
                *reason_r = "Invalid certificate";
                return FALSE;
        }
@@ -730,7 +730,7 @@ openssl_iostream_get_peer_username(struct ssl_iostream *ssl_io)
        char *name;
        int len;
 
-       if (!ssl_iostream_has_valid_client_cert(ssl_io))
+       if (!ssl_iostream_has_valid_cert(ssl_io))
                return NULL;
 
 #ifdef HAVE_SSL_get1_peer_certificate
index df5d218f2399b93929bcec9fd83d55bf6469e059..bac0fa09acb41cc3c9bf190ce6e0cc1d4faf4296 100644 (file)
@@ -269,12 +269,12 @@ bool ssl_iostream_is_handshaked(const struct ssl_iostream *ssl_io)
        return ssl_iostream_get_state(ssl_io) == SSL_IOSTREAM_STATE_OK;
 }
 
-bool ssl_iostream_has_valid_client_cert(const struct ssl_iostream *ssl_io)
+bool ssl_iostream_has_valid_cert(const struct ssl_iostream *ssl_io)
 {
        return ssl_vfuncs->get_cert_validity(ssl_io) == SSL_IOSTREAM_CERT_VALIDITY_OK;
 }
 
-bool ssl_iostream_has_client_cert(struct ssl_iostream *ssl_io)
+bool ssl_iostream_has_cert(struct ssl_iostream *ssl_io)
 {
        return ssl_vfuncs->get_cert_validity(ssl_io) != SSL_IOSTREAM_CERT_VALIDITY_NO_CERT;
 }
@@ -291,8 +291,8 @@ ssl_iostream_check_cert_validity(struct ssl_iostream *ssl_io,
 {
        const char *reason;
 
-       if (!ssl_iostream_has_valid_client_cert(ssl_io)) {
-               if (!ssl_iostream_has_client_cert(ssl_io)) {
+       if (!ssl_iostream_has_valid_cert(ssl_io)) {
+               if (!ssl_iostream_has_cert(ssl_io)) {
                        *error_r = "SSL certificate not received";
                        return SSL_IOSTREAM_CERT_VALIDITY_NO_CERT;
                } else {
index 3c5f2d616a533594581a2de75a4ff2df3e03ea88..6fd06a9ef46b3d09f2b6b0e14fec3fe41437c2d2 100644 (file)
@@ -205,8 +205,13 @@ ssl_iostream_get_state(const struct ssl_iostream *ssl_io);
 /* Returns TRUE if SSL iostream handshake is finished and certificate is valid.
    This is the same as state being SSL_IOSTREAM_STATE_OK. */
 bool ssl_iostream_is_handshaked(const struct ssl_iostream *ssl_io);
-bool ssl_iostream_has_valid_client_cert(const struct ssl_iostream *ssl_io);
-bool ssl_iostream_has_client_cert(struct ssl_iostream *ssl_io);
+/* Returns TRUE if SSL (client or server) certificate was received,
+   valid or not. */
+bool ssl_iostream_has_cert(struct ssl_iostream *ssl_io);
+/* Returns TRUE if a valid SSL (client or server) certificate was received.
+   Certificate name validity isn't checked, ssl_iostream_cert_match_name() must
+   be used for that. */
+bool ssl_iostream_has_valid_cert(const struct ssl_iostream *ssl_io);
 /* Checks certificate validity based, also performs name checking. Called by
    default in handshake, unless handshake callback is set with
    ssl_iostream_check_cert_validity().
@@ -214,7 +219,7 @@ bool ssl_iostream_has_client_cert(struct ssl_iostream *ssl_io);
    Host should be set as the name you want to validate the certificate name(s)
    against. Usually this is the host name you connected to.
 
-   This function is same as calling ssl_iostream_has_valid_client_cert()
+   This function is same as calling ssl_iostream_has_valid_cert()
    and ssl_iostream_cert_match_name().
  */
 enum ssl_iostream_cert_validity
index 508b799d0061824a3b3e5bb26c3d4c6ccea7f190..821314b0a6e957c51c92c07165733582f9dc0d64 100644 (file)
@@ -1392,13 +1392,13 @@ bool client_get_extra_disconnect_reason(struct client *client,
                        *human_reason_r = "cert required, client didn't start TLS";
                        return TRUE;
                }
-               if (!ssl_iostream_has_client_cert(client->ssl_iostream)) {
+               if (!ssl_iostream_has_cert(client->ssl_iostream)) {
                        *event_reason_r = "client_ssl_cert_missing";
                        *human_reason_r = "client didn't send a cert";
                        return TRUE;
                }
                if (client->ssl_server_set->parsed_opts.verify_client_cert &&
-                   !ssl_iostream_has_valid_client_cert(client->ssl_iostream)) {
+                   !ssl_iostream_has_valid_cert(client->ssl_iostream)) {
                        *event_reason_r = "client_ssl_cert_untrusted";
                        *human_reason_r = "client sent an untrusted cert";
                        return TRUE;
index 9d4bb024e394645f1015afa6e189ed4c481b3d68..c1cfebf70cbbacb39cc981b828de473910ca7d7c 100644 (file)
@@ -124,7 +124,7 @@ client_get_auth_flags(struct client *client)
         enum auth_request_flags auth_flags = 0;
 
        if (client->ssl_iostream != NULL &&
-           ssl_iostream_has_valid_client_cert(client->ssl_iostream))
+           ssl_iostream_has_valid_cert(client->ssl_iostream))
                auth_flags |= AUTH_REQUEST_FLAG_VALID_CLIENT_CERT;
        if (client->connection_tls_secured)
                auth_flags |= AUTH_REQUEST_FLAG_CONN_SECURED_TLS;
@@ -477,7 +477,7 @@ get_cert_username(struct client *client, const char **username_r,
        }
 
        /* no client certificate */
-       if (!ssl_iostream_has_valid_client_cert(client->ssl_iostream)) {
+       if (!ssl_iostream_has_valid_cert(client->ssl_iostream)) {
                *username_r = NULL;
                return TRUE;
        }