]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: Remove ssl_iostream_has_handshake_failed()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 8 Aug 2025 11:57:02 +0000 (14:57 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 11 Aug 2025 07:47:35 +0000 (07:47 +0000)
Its meaning is a bit too ambiguous. It's better for callers to use
ssl_iostream_get_state().

src/lib-ssl-iostream/iostream-openssl.c
src/lib-ssl-iostream/iostream-ssl.c
src/lib-ssl-iostream/iostream-ssl.h
src/lib-ssl-iostream/test-iostream-ssl.c

index 7d33c678fa7bd94ce32fa43961677ea9afc3dbe6..ea5b2d72fd2493e9841a92955ae1385e1976e347 100644 (file)
@@ -707,12 +707,6 @@ openssl_iostream_get_state(const struct ssl_iostream *ssl_io)
        return ssl_io->state;
 }
 
-static bool
-openssl_iostream_has_handshake_failed(const struct ssl_iostream *ssl_io)
-{
-       return ssl_io->handshake_failed;
-}
-
 static bool
 openssl_iostream_has_valid_client_cert(const struct ssl_iostream *ssl_io)
 {
@@ -1104,7 +1098,6 @@ static const struct iostream_ssl_vfuncs ssl_vfuncs = {
 
        .set_log_prefix = openssl_iostream_set_log_prefix,
        .get_state = openssl_iostream_get_state,
-       .has_handshake_failed = openssl_iostream_has_handshake_failed,
        .has_valid_client_cert = openssl_iostream_has_valid_client_cert,
        .has_client_cert = openssl_iostream_has_client_cert,
        .cert_match_name = openssl_iostream_cert_match_name,
index 67e6b27d2be0285a804e553987cb20fd4119a585..3cd8fe93948539859303138097d1210a13ab8bd0 100644 (file)
@@ -269,11 +269,6 @@ 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_handshake_failed(const struct ssl_iostream *ssl_io)
-{
-       return ssl_vfuncs->has_handshake_failed(ssl_io);
-}
-
 bool ssl_iostream_has_valid_client_cert(const struct ssl_iostream *ssl_io)
 {
        return ssl_vfuncs->has_valid_client_cert(ssl_io);
index 8e6068f4e693602dc024b3bb90d616b2da8752cc..3c5f2d616a533594581a2de75a4ff2df3e03ea88 100644 (file)
@@ -205,9 +205,6 @@ 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);
-/* Returns TRUE if the remote cert is invalid, or handshake callback returned
-   failure. */
-bool ssl_iostream_has_handshake_failed(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);
 /* Checks certificate validity based, also performs name checking. Called by
index e2e20d092279443e9492e6d99972099c2fb31f7d..efd96d165595ae5c120c5b2b6788b95694a5521d 100644 (file)
@@ -239,10 +239,12 @@ static int test_iostream_ssl_handshake_real(struct ssl_iostream_settings *server
        if (client->failed || server->failed)
                ret = -1;
 
-       if (ssl_iostream_has_handshake_failed(client->iostream)) {
+       if (ssl_iostream_get_state(client->iostream) != SSL_IOSTREAM_STATE_OK &&
+           ssl_iostream_get_state(client->iostream) != SSL_IOSTREAM_STATE_HANDSHAKING) {
                i_error("client: %s", ssl_iostream_get_last_error(client->iostream));
                ret = -1;
-       } else if (ssl_iostream_has_handshake_failed(server->iostream)) {
+       } else if (ssl_iostream_get_state(server->iostream) != SSL_IOSTREAM_STATE_OK &&
+                  ssl_iostream_get_state(server->iostream) != SSL_IOSTREAM_STATE_HANDSHAKING) {
                i_error("server: %s", ssl_iostream_get_last_error(server->iostream));
                ret = -1;
        /* check hostname */