X-Git-Url: https://ruderich.org/simon/gitweb/?p=tlsproxy%2Ftlsproxy.git;a=blobdiff_plain;f=src%2Fverify.c;h=34a081493e81b1a41ef044ff69dffb77d2c8ef99;hp=f6742361f3e9d111a4bc779c246a10d11914a6fe;hb=b7ce41b809a3b3533d398c0da8fd9787c149434c;hpb=5d7fb12f931f04e29100e690ba06486f5d3be0b7 diff --git a/src/verify.c b/src/verify.c index f674236..34a0814 100644 --- a/src/verify.c +++ b/src/verify.c @@ -49,7 +49,8 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) { * more checks. */ if (result < 0) { LOG(WARNING, - "verify_tls_connection(): gnutls_certificate_verify_peers2() failed: %s", + "verify_tls_connection(): " + "gnutls_certificate_verify_peers2() failed: %s", gnutls_strerror(result)); return -1; } @@ -58,8 +59,7 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) { || status & GNUTLS_CERT_REVOKED || status & GNUTLS_CERT_NOT_ACTIVATED || status & GNUTLS_CERT_INSECURE_ALGORITHM) { - LOG(WARNING, - "verify_tls_connection(): invalid server certificate"); + LOG(WARNING, "verify_tls_connection(): invalid server certificate"); return -1; } @@ -67,8 +67,7 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) { * prevent an attacker from changing the certificate type to prevent * detection. */ if (gnutls_certificate_type_get(session) != GNUTLS_CRT_X509) { - LOG(WARNING, - "verify_tls_connection(): no X509 server certificate"); + LOG(WARNING, "verify_tls_connection(): no X509 server certificate"); return -1; } @@ -137,9 +136,8 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) { strcat(stored_cert, buffer); } if (ferror(file)) { - LOG(WARNING, - "verify_tls_connection(): failed to read from '%s': %s", - path, strerror(errno)); + LOG(WARNING, "verify_tls_connection(): failed to read from '%s': %s", + path, strerror(errno)); fclose(file); LOG(DEBUG, "server certificate:\n%s", server_cert); @@ -149,9 +147,8 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) { /* Check if the server certificate matches our stored certificate. */ if (strcmp(stored_cert, server_cert)) { - LOG(ERROR, - "verify_tls_connection(): server certificate changed!", - path, strerror(errno)); + LOG(ERROR, "verify_tls_connection(): server certificate changed!", + path, strerror(errno)); LOG(WARNING, "server certificate:\n%s", server_cert); return -2; @@ -183,16 +180,14 @@ static int get_certificate_path(const char *format, /* Hostname too long. */ assert(size > strlen(format)); if (size - strlen(format) <= strlen(hostname)) { - LOG(WARNING, - "get_certificate_path(): hostname too long: '%s'", - hostname); + LOG(WARNING, "get_certificate_path(): hostname too long: '%s'", + hostname); return -1; } /* Try to prevent path traversals in hostnames. */ if (strstr(hostname, "..") != NULL) { - LOG(WARNING, - "get_certificate_path(): possible path traversal: '%s'", - hostname); + LOG(WARNING, "get_certificate_path(): possible path traversal: '%s'", + hostname); return -1; } /* Safe as format is no user input. */ @@ -217,8 +212,7 @@ int server_certificate_file(FILE **file, const char *hostname, char *path, size_t size) { if (get_certificate_path(STORED_SERVER_CERT_FORMAT, hostname, path, size) != 0) { - LOG_PERROR(ERROR, - "server_certificate_file(): failed to get path"); + LOG_PERROR(ERROR, "server_certificate_file(): failed to get path"); return -1; } @@ -226,13 +220,11 @@ int server_certificate_file(FILE **file, const char *hostname, *file = fopen(path, "rb"); if (*file == NULL) { if (global_passthrough_unknown) { - LOG(DEBUG, - "server_certificate_file(): failed to open '%s': %s", - path, strerror(errno)); + LOG(DEBUG, "server_certificate_file(): failed to open '%s': %s", + path, strerror(errno)); } else { - LOG(WARNING, - "server_certificate_file(): failed to open '%s': %s", - path, strerror(errno)); + LOG(WARNING, "server_certificate_file(): failed to open '%s': %s", + path, strerror(errno)); } /* Couldn't open the file, special case. */ return -2;