X-Git-Url: https://vcs.fsf.org/?p=exim.git;a=blobdiff_plain;f=src%2Fsrc%2Ftls-openssl.c;h=58401e93289d5018d036b956d34fe2b2b851cc88;hp=3aade3b9e6870a8cce190d15254c2cc70f8f3fe4;hb=ea792dac9f89e1a0b396e6c8982ff04afafe91be;hpb=6600985a2331eeaa8af525eb627edfe08b1a2e9c diff --git a/src/src/tls-openssl.c b/src/src/tls-openssl.c index 3aade3b9e..58401e932 100644 --- a/src/src/tls-openssl.c +++ b/src/src/tls-openssl.c @@ -29,7 +29,7 @@ functions from the OpenSSL library. */ # include #endif #ifdef EXPERIMENTAL_DANE -# include +# include "danessl.h" #endif @@ -46,7 +46,6 @@ functions from the OpenSSL library. */ #endif #if OPENSSL_VERSION_NUMBER >= 0x10100000L # define EXIM_HAVE_OCSP_RESP_COUNT -# define EXIM_HAVE_OPENSSL_DH_BITS #else # define EXIM_HAVE_EPHEM_RSA_KEX # define EXIM_HAVE_RAND_PSEUDO @@ -70,6 +69,7 @@ functions from the OpenSSL library. */ #ifndef LIBRESSL_VERSION_NUMBER # if OPENSSL_VERSION_NUMBER >= 0x010100000L # define EXIM_HAVE_OPENSSL_CHECKHOST +# define EXIM_HAVE_OPENSSL_DH_BITS # endif # if OPENSSL_VERSION_NUMBER >= 0x010000000L \ && (OPENSSL_VERSION_NUMBER & 0x0000ff000L) >= 0x000002000L @@ -384,11 +384,13 @@ dn[sizeof(dn)-1] = '\0'; if (preverify_ok == 0) { - log_write(0, LOG_MAIN, "[%s] SSL verify error: depth=%d error=%s cert=%s", - tlsp == &tls_out ? deliver_host_address : sender_host_address, - depth, - X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509ctx)), - dn); + uschar * extra = verify_mode ? string_sprintf(" (during %c-verify for [%s])", + *verify_mode, sender_host_address) + : US""; + log_write(0, LOG_MAIN, "[%s] SSL verify error%s: depth=%d error=%s cert=%s", + tlsp == &tls_out ? deliver_host_address : sender_host_address, + extra, depth, + X509_verify_cert_error_string(X509_STORE_CTX_get_error(x509ctx)), dn); *calledp = TRUE; if (!*optionalp) { @@ -449,7 +451,7 @@ else if (rc < 0) { log_write(0, LOG_MAIN, "[%s] SSL verify error: internal error", - deliver_host_address); + tlsp == &tls_out ? deliver_host_address : sender_host_address); name = NULL; } break; @@ -459,10 +461,14 @@ else if (!tls_is_name_for_cert(verify_cert_hostnames, cert)) #endif { + uschar * extra = verify_mode + ? string_sprintf(" (during %c-verify for [%s])", + *verify_mode, sender_host_address) + : US""; log_write(0, LOG_MAIN, - "[%s] SSL verify error: certificate name mismatch: " - "DN=\"%s\" H=\"%s\"", - deliver_host_address, dn, verify_cert_hostnames); + "[%s] SSL verify error%s: certificate name mismatch: DN=\"%s\" H=\"%s\"", + tlsp == &tls_out ? deliver_host_address : sender_host_address, + extra, dn, verify_cert_hostnames); *calledp = TRUE; if (!*optionalp) { @@ -1493,9 +1499,9 @@ if (!RAND_status()) gettimeofday(&r.tv, NULL); r.p = getpid(); - RAND_seed((uschar *)(&r), sizeof(r)); - RAND_seed((uschar *)big_buffer, big_buffer_size); - if (addr != NULL) RAND_seed((uschar *)addr, sizeof(addr)); + RAND_seed(US (&r), sizeof(r)); + RAND_seed(US big_buffer, big_buffer_size); + if (addr != NULL) RAND_seed(US addr, sizeof(addr)); if (!RAND_status()) return tls_error(US"RAND_status", host, @@ -2567,11 +2573,10 @@ tls_write(BOOL is_server, const uschar *buff, size_t len, BOOL more) { int outbytes, error, left; SSL *ssl = is_server ? server_ssl : client_ssl; -static uschar * corked = NULL; -static int c_size = 0, c_len = 0; +static gstring * corked = NULL; -DEBUG(D_tls) debug_printf("%s(%p, %d%s)\n", __FUNCTION__, - buff, left, more ? ", more" : ""); +DEBUG(D_tls) debug_printf("%s(%p, %lu%s)\n", __FUNCTION__, + buff, (unsigned long)len, more ? ", more" : ""); /* Lacking a CORK or MSG_MORE facility (such as GnuTLS has) we copy data when "more" is notified. This hack is only ok if small amounts are involved AND only @@ -2580,12 +2585,12 @@ for the responses to the received SMTP MAIL , RCPT, DATA sequence, only. */ if (is_server && (more || corked)) { - corked = string_catn(corked, &c_size, &c_len, buff, len); + corked = string_catn(corked, buff, len); if (more) return len; - buff = CUS corked; - len = c_len; - corked = NULL; c_size = c_len = 0; + buff = CUS corked->s; + len = corked->ptr; + corked = NULL; } for (left = len; left > 0;) @@ -2813,7 +2818,7 @@ if (!RAND_status()) gettimeofday(&r.tv, NULL); r.p = getpid(); - RAND_seed((uschar *)(&r), sizeof(r)); + RAND_seed(US (&r), sizeof(r)); } /* We're after pseudo-random, not random; if we still don't have enough data in the internal PRNG then our options are limited. We could sleep and hope