}
if (!preverify_ok) {
ssl_io->cert_broken = TRUE;
- if (ssl_io->require_valid_cert)
+ if (ssl_io->require_valid_cert) {
+ ssl_io->handshake_failed = TRUE;
return 0;
+ }
}
return 1;
}
i_stream_close(ssl_io->plain_input);
o_stream_close(ssl_io->plain_output);
openssl_iostream_set_error(ssl_io, error);
+ ssl_io->handshake_failed = TRUE;
errno = EINVAL;
return -1;
}
return ssl_io->handshaked;
}
+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)
{
openssl_iostream_set_log_prefix,
openssl_iostream_is_handshaked,
+ openssl_iostream_has_handshake_failed,
openssl_iostream_has_valid_client_cert,
openssl_iostream_has_broken_client_cert,
openssl_iostream_cert_match_name,
void *handshake_context;
unsigned int handshaked:1;
+ unsigned int handshake_failed:1;
unsigned int cert_received:1;
unsigned int cert_broken:1;
unsigned int want_read:1;
void (*set_log_prefix)(struct ssl_iostream *ssl_io, const char *prefix);
bool (*is_handshaked)(const struct ssl_iostream *ssl_io);
+ bool (*has_handshake_failed)(const struct ssl_iostream *ssl_io);
bool (*has_valid_client_cert)(const struct ssl_iostream *ssl_io);
bool (*has_broken_client_cert)(struct ssl_iostream *ssl_io);
int (*cert_match_name)(struct ssl_iostream *ssl_io, const char *name);
return ssl_vfuncs->is_handshaked(ssl_io);
}
+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);
void *context);
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_broken_client_cert(struct ssl_iostream *ssl_io);
int ssl_iostream_check_cert_validity(struct ssl_iostream *ssl_io,