Path: blob/main/mail/cclient/files/patch-src_osdep_unix_ssl__unix.c
16131 views
Description: Support OpenSSL 1.11When building with OpenSSL 1.1 and newer, use the new built-in2hostname verification instead of code that doesn't compile due to3structs having been made opaque.4Bug-Debian: https://bugs.debian.org/82858956Obtained from: https://sources.debian.org/data/main/u/uw-imap/8:2007f~dfsg-5/debian/patches/1006_openssl1.1_autoverify.patch7--- src/osdep/unix/ssl_unix.c.orig8+++ src/osdep/unix/ssl_unix.c9@@ -227,8 +227,16 @@ static char *ssl_start_work (SSLSTREAM *10/* disable certificate validation? */11if (flags & NET_NOVALIDATECERT)12SSL_CTX_set_verify (stream->context,SSL_VERIFY_NONE,NIL);13- else SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify);14+ else {15+#if OPENSSL_VERSION_NUMBER >= 0x1010000016+ X509_VERIFY_PARAM *param = SSL_CTX_get0_param(stream->context);17+ X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS);18+ X509_VERIFY_PARAM_set1_host(param, host, 0);19+#endif20+21+ SSL_CTX_set_verify (stream->context,SSL_VERIFY_PEER,ssl_open_verify);22/* set default paths to CAs... */23+ }24SSL_CTX_set_default_verify_paths (stream->context);25/* ...unless a non-standard path desired */26if (s = (char *) mail_parameters (NIL,GET_SSLCAPATH,NIL))27@@ -266,6 +274,7 @@ static char *ssl_start_work (SSLSTREAM *28if (SSL_write (stream->con,"",0) < 0)29return ssl_last_error ? ssl_last_error : "SSL negotiation failed";30/* need to validate host names? */31+#if OPENSSL_VERSION_NUMBER < 0x1010000032if (!(flags & NET_NOVALIDATECERT) &&33(err = ssl_validate_cert (cert = SSL_get_peer_certificate (stream->con),34host))) {35@@ -275,6 +284,7 @@ static char *ssl_start_work (SSLSTREAM *36sprintf (tmp,"*%.128s: %.255s",err,cert ? cert->name : "???");37return ssl_last_error = cpystr (tmp);38}39+#endif40return NIL;41}4243@@ -313,6 +323,7 @@ static int ssl_open_verify (int ok,X509_44* Returns: NIL if validated, else string of error message45*/4647+#if OPENSSL_VERSION_NUMBER < 0x1010000048static char *ssl_validate_cert (X509 *cert,char *host)49{50int i,n;51@@ -342,6 +353,7 @@ static char *ssl_validate_cert (X509 *ce52else ret = "Unable to locate common name in certificate";53return ret;54}55+#endif5657/* Case-independent wildcard pattern match58* Accepts: base string596061