X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=src%2Fconnection.c;h=ad7298a876033dd3b37e7303901506c9f4b9b463;hb=730ce301477d9d5c9367756bad840eb4504e0257;hp=15eb321d811965d4f0b1a71c72659fb500a3d5ea;hpb=83965c106ac6a33d1c4248b7ccae93de438f7727;p=tlsproxy%2Ftlsproxy.git diff --git a/src/connection.c b/src/connection.c index 15eb321..ad7298a 100644 --- a/src/connection.c +++ b/src/connection.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -785,6 +786,22 @@ static int read_from_write_to_tls(gnutls_session_t from, size_read = gnutls_record_recv(from, buffer, buffer_size); if (size_read < 0) { + /* Allow rehandshakes. As handshakes might be insecure make sure that + * %SAFE_RENEGOTIATION is used in GnuTLS's priority string. */ + if (size_read == GNUTLS_E_REHANDSHAKE) { + int result; + + LOG(DEBUG1, "server requested TLS rehandshake"); + + result = gnutls_handshake(from); + if (result != GNUTLS_E_SUCCESS) { + LOG(WARNING, "server TLS rehandshake failed: %s", + gnutls_strerror(result)); + return -1; + } + return 0; + } + LOG(WARNING, "read_from_write_to_tls(): gnutls_record_recv(): %s", gnutls_strerror((int)size_read)); return -1; @@ -828,7 +845,7 @@ static int connect_to_host(const char *hostname, const char *port) { gai_hints.ai_protocol = 0; gai_hints.ai_flags = AI_NUMERICSERV /* given port is numeric */ | AI_ADDRCONFIG /* supported by this computer */ - | AI_V4MAPPED; /* support IPv4 through IPv6 */ + ; gai_return = getaddrinfo(hostname, port, &gai_hints, &gai_result); if (gai_return != 0) { if (gai_return == EAI_SYSTEM) {