]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/commitdiff
src/connection.c: Move path related defines to tlsproxy.h.
authorSimon Ruderich <simon@ruderich.org>
Thu, 10 Mar 2011 23:18:36 +0000 (00:18 +0100)
committerSimon Ruderich <simon@ruderich.org>
Thu, 10 Mar 2011 23:18:36 +0000 (00:18 +0100)
Thus all file constants are stored in one place.

src/connection.c
src/tlsproxy.h

index 7ea6eb24a7573dd14d5d21facf89a06dc2546c9d..26947ffdbfd60968e3c0b229b188161a2767ba8f 100644 (file)
  * should be a good limit to make processing simpler. */
 #define MAX_REQUEST_LINE 4096
 
-/* Paths to necessary TLS files: the CA and the server key. */
-#define PROXY_CA_FILE  "proxy-ca.pem"
-#define PROXY_KEY_FILE "proxy-key.pem"
-
 
 static int initialize_tls_session_client(int peer_socket,
         const char *hostname,
@@ -284,12 +280,9 @@ static int initialize_tls_session_client(int peer_socket,
         gnutls_certificate_credentials_t *x509_cred) {
     int result;
     char path[1024];
-    /* The server certificate for the given hostname is stored in
-     * "./certificate-hostname-proxy.pem". */
-#define PATH_FORMAT "./certificate-%s-proxy.pem"
 
     /* Hostname too long. */
-    if (sizeof(path) - strlen(PATH_FORMAT) <= strlen(hostname)) {
+    if (sizeof(path) - strlen(PROXY_SERVER_CERT_FORMAT) <= strlen(hostname)) {
         LOG(LOG_WARNING,
             "initialize_tls_session_client(): hostname too long: '%s'",
             hostname);
@@ -302,8 +295,7 @@ static int initialize_tls_session_client(int peer_socket,
             hostname);
         return -1;
     }
-    snprintf(path, sizeof(path), PATH_FORMAT, hostname);
-#undef PATH_FORMAT
+    snprintf(path, sizeof(path), PROXY_SERVER_CERT_FORMAT, hostname);
 
     result = gnutls_certificate_allocate_credentials(x509_cred);
     if (GNUTLS_E_SUCCESS != result) {
index 8ade4e8c6d4d6ceabed12e9523ceb7783ad56d43..9c908084945857c49275b4fa90ae0135d87e8530 100644 (file)
 #include "log.h"
 
 
+/* Paths to necessary TLS files: the CA and the server key. */
+#define PROXY_CA_FILE  "proxy-ca.pem"
+#define PROXY_KEY_FILE "proxy-key.pem"
+/* The server certificate for the given hostname is stored in
+ * "./certificate-hostname-proxy.pem" - we use this for the connection to the
+ * client. */
+#define PROXY_SERVER_CERT_FORMAT "./certificate-%s-proxy.pem"
 
 
 /* Proxy hostname and port if specified on the command line. */