]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/blobdiff - src/verify.c
src/verify.c: Better handle a missing proxy certificate.
[tlsproxy/tlsproxy.git] / src / verify.c
index f546fd42e2cb9d2982cea39a0c0a6fd8b112b6a0..5de9d84d0517737daf5c07a2b73919bb37c14b86 100644 (file)
@@ -156,6 +156,21 @@ int verify_tls_connection(gnutls_session_t session, const char *hostname) {
         return -2;
     }
 
+    /* Check that the proxy certificate file exists and is readable for this
+     * domain. This ensures we send an "invalid" certificate even if the proxy
+     * certificate doesn't exist. */
+    if (0 != proxy_certificate_path(hostname, path, sizeof(path))) {
+        return -1;
+    }
+    file = fopen(path, "r");
+    if (NULL == file) {
+        LOG(LOG_WARNING,
+            "verify_tls_connection(): proxy certificate doesn't exist: '%s'",
+            path);
+        return -1;
+    }
+    fclose(file);
+
     return 0;
 }