]> ruderich.org/simon Gitweb - tlsproxy/tlsproxy.git/blob - src/tlsproxy.h
692278e7fa4e0b5184fe19c6d38d631af69ca2cc
[tlsproxy/tlsproxy.git] / src / tlsproxy.h
1 /*
2  * Global variables/defines.
3  *
4  * Copyright (C) 2011-2013  Simon Ruderich
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef TLSPROXY_H
21 #define TLSPROXY_H
22
23 #include <config.h>
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h>
29
30 #include <gnutls/gnutls.h>
31
32 #include "log.h"
33
34
35 /* Length for path arrays. */
36 #define TLSPROXY_MAX_PATH_LENGTH 1024
37
38 /* Paths to proxy files: the CA, the server key and DH parameters. */
39 #define PROXY_CA_PATH  "proxy-ca.pem"
40 #define PROXY_KEY_PATH "proxy-key.pem"
41 #define PROXY_DH_PATH  "proxy-dh.pem"
42 /* Path to special "invalid" certificate send to the client when an error
43  * occurs. */
44 #define PROXY_INVALID_CERT_PATH "proxy-invalid.pem"
45 /* The server certificate for the given hostname is stored in
46  * "./certificate-hostname-proxy.pem" - we use this for the connection to the
47  * client. */
48 #define PROXY_SERVER_CERT_FILE_FORMAT "./certificate-%s-proxy.pem"
49 /* The remote server certificate for the given hostname is stored in
50  * "./certificate-hostname-proxy.pem" - we make sure the server sends this
51  * certificate. */
52 #define STORED_SERVER_CERT_FILE_FORMAT "./certificate-%s-server.pem"
53
54 /* GnuTLS priority string used for both server and client connections. */
55 #define PROXY_TLS_PRIORITIES \
56     /* Don't use known insecure algorithms. */ \
57     "SECURE" \
58     /* Lower priority of SHA-1, user better hashes if possible. */ \
59     ":-SHA1:+SHA1" \
60     /* Force safe renegotiations. Shouldn't cause any problems as this \
61      * option only affects the server side (with GnuTLS defaults) and the \
62      * local clients most-likely already support safe renegotiations (old \
63      * servers are therefore not an issue). */ \
64     ":%SAFE_RENEGOTIATION"
65
66
67 /* Proxy hostname and port if specified on the command line. */
68 char *global_proxy_host;
69 char *global_proxy_port;
70
71 /* Passphrase for authentication of this proxy. Used with the -a option. */
72 char *global_http_digest_authorization;
73
74 /* Log level, command line option. */
75 int global_log_level;
76
77 /* Passthrough connections if no certificate is stored for this hostname?
78  * Specified on the command line. */
79 int global_passthrough_unknown;
80
81 /* "Global" GnuTLS data used by all threads, read only. */
82 gnutls_priority_t global_tls_priority_cache;
83 gnutls_dh_params_t global_tls_dh_params;
84
85 /* Very simple compile time asserts. No good error message though. */
86 #define ct_assert(x) { \
87     int unused[(x) ? 1 : -1]; \
88     (void)unused; \
89 }
90
91 #endif