This code is always enabled and removing the #ifdef make the code a little bit clearer
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: James Yonan <james@openvpn.net>
Message-Id: 1340044749-10694-4-git-send-email-arne@rfc2549.org
URL: http://article.gmane.org/gmane.network.openvpn.devel/6746
Signed-off-by: David Sommerseth <davids@redhat.com>
| ... | ... |
@@ -737,7 +737,6 @@ get_tls_handshake_key (const struct key_type *key_type, |
| 737 | 737 |
kt.cipher_length = 0; |
| 738 | 738 |
kt.cipher = NULL; |
| 739 | 739 |
|
| 740 |
-#if ENABLE_INLINE_FILES |
|
| 741 | 740 |
if (flags & GHK_INLINE) |
| 742 | 741 |
{
|
| 743 | 742 |
/* key was specified inline, key text is in passphrase_file */ |
| ... | ... |
@@ -750,7 +749,6 @@ get_tls_handshake_key (const struct key_type *key_type, |
| 750 | 750 |
msg (M_FATAL, "INLINE tls-auth file lacks the requisite 2 keys"); |
| 751 | 751 |
} |
| 752 | 752 |
else |
| 753 |
-#endif |
|
| 754 | 753 |
{
|
| 755 | 754 |
/* first try to parse as an OpenVPN static key file */ |
| 756 | 755 |
read_key_file (&key2, passphrase_file, 0); |
| ... | ... |
@@ -857,7 +855,6 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags) |
| 857 | 857 |
* Key can be provided as a filename in 'file' or if RKF_INLINE |
| 858 | 858 |
* is set, the actual key data itself in ascii form. |
| 859 | 859 |
*/ |
| 860 |
-#if ENABLE_INLINE_FILES |
|
| 861 | 860 |
if (flags & RKF_INLINE) /* 'file' is a string containing ascii representation of key */ |
| 862 | 861 |
{
|
| 863 | 862 |
size = strlen (file) + 1; |
| ... | ... |
@@ -865,7 +862,6 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags) |
| 865 | 865 |
error_filename = INLINE_FILE_TAG; |
| 866 | 866 |
} |
| 867 | 867 |
else /* 'file' is a filename which refers to a file containing the ascii key */ |
| 868 |
-#endif |
|
| 869 | 868 |
{
|
| 870 | 869 |
in = alloc_buf_gc (2048, &gc); |
| 871 | 870 |
fd = platform_open (file, O_RDONLY, 0); |
| ... | ... |
@@ -979,9 +975,7 @@ read_key_file (struct key2 *key2, const char *file, const unsigned int flags) |
| 979 | 979 |
} |
| 980 | 980 |
|
| 981 | 981 |
/* zero file read buffer if not an inline file */ |
| 982 |
-#if ENABLE_INLINE_FILES |
|
| 983 | 982 |
if (!(flags & RKF_INLINE)) |
| 984 |
-#endif |
|
| 985 | 983 |
buf_clear (&in); |
| 986 | 984 |
|
| 987 | 985 |
if (key2->n) |
| ... | ... |
@@ -2053,13 +2053,11 @@ do_init_crypto_static (struct context *c, const unsigned int flags) |
| 2053 | 2053 |
unsigned int rkf_flags = RKF_MUST_SUCCEED; |
| 2054 | 2054 |
const char *rkf_file = options->shared_secret_file; |
| 2055 | 2055 |
|
| 2056 |
-#if ENABLE_INLINE_FILES |
|
| 2057 | 2056 |
if (options->shared_secret_file_inline) |
| 2058 | 2057 |
{
|
| 2059 | 2058 |
rkf_file = options->shared_secret_file_inline; |
| 2060 | 2059 |
rkf_flags |= RKF_INLINE; |
| 2061 | 2060 |
} |
| 2062 |
-#endif |
|
| 2063 | 2061 |
read_key_file (&key2, rkf_file, rkf_flags); |
| 2064 | 2062 |
} |
| 2065 | 2063 |
|
| ... | ... |
@@ -2153,13 +2151,11 @@ do_init_crypto_tls_c1 (struct context *c) |
| 2153 | 2153 |
unsigned int flags = 0; |
| 2154 | 2154 |
const char *file = options->tls_auth_file; |
| 2155 | 2155 |
|
| 2156 |
-#if ENABLE_INLINE_FILES |
|
| 2157 | 2156 |
if (options->tls_auth_file_inline) |
| 2158 | 2157 |
{
|
| 2159 | 2158 |
flags |= GHK_INLINE; |
| 2160 | 2159 |
file = options->tls_auth_file_inline; |
| 2161 | 2160 |
} |
| 2162 |
-#endif |
|
| 2163 | 2161 |
get_tls_handshake_key (&c->c1.ks.key_type, |
| 2164 | 2162 |
&c->c1.ks.tls_auth_key, |
| 2165 | 2163 |
file, |
| ... | ... |
@@ -205,9 +205,7 @@ warn_if_group_others_accessible (const char* filename) |
| 205 | 205 |
{
|
| 206 | 206 |
#ifndef WIN32 |
| 207 | 207 |
#ifdef HAVE_STAT |
| 208 |
-#if ENABLE_INLINE_FILES |
|
| 209 | 208 |
if (strcmp (filename, INLINE_FILE_TAG)) |
| 210 |
-#endif |
|
| 211 | 209 |
{
|
| 212 | 210 |
struct stat st; |
| 213 | 211 |
if (stat (filename, &st)) |
| ... | ... |
@@ -1524,7 +1522,6 @@ make_arg_array (const char *first, const char *parms, struct gc_arena *gc) |
| 1524 | 1524 |
return (const char **)ret; |
| 1525 | 1525 |
} |
| 1526 | 1526 |
|
| 1527 |
-#if ENABLE_INLINE_FILES |
|
| 1528 | 1527 |
static const char ** |
| 1529 | 1528 |
make_inline_array (const char *str, struct gc_arena *gc) |
| 1530 | 1529 |
{
|
| ... | ... |
@@ -1553,7 +1550,6 @@ make_inline_array (const char *str, struct gc_arena *gc) |
| 1553 | 1553 |
ret[i] = NULL; |
| 1554 | 1554 |
return (const char **)ret; |
| 1555 | 1555 |
} |
| 1556 |
-#endif |
|
| 1557 | 1556 |
|
| 1558 | 1557 |
static const char ** |
| 1559 | 1558 |
make_arg_copy (char **p, struct gc_arena *gc) |
| ... | ... |
@@ -1576,11 +1572,9 @@ const char ** |
| 1576 | 1576 |
make_extended_arg_array (char **p, struct gc_arena *gc) |
| 1577 | 1577 |
{
|
| 1578 | 1578 |
const int argc = string_array_len ((const char **)p); |
| 1579 |
-#if ENABLE_INLINE_FILES |
|
| 1580 | 1579 |
if (!strcmp (p[0], INLINE_FILE_TAG) && argc == 2) |
| 1581 | 1580 |
return make_inline_array (p[1], gc); |
| 1582 | 1581 |
else |
| 1583 |
-#endif |
|
| 1584 | 1582 |
if (argc == 0) |
| 1585 | 1583 |
return make_arg_array (NULL, NULL, gc); |
| 1586 | 1584 |
else if (argc == 1) |
| ... | ... |
@@ -3683,8 +3683,6 @@ bypass_doubledash (char **p) |
| 3683 | 3683 |
*p += 2; |
| 3684 | 3684 |
} |
| 3685 | 3685 |
|
| 3686 |
-#if ENABLE_INLINE_FILES |
|
| 3687 |
- |
|
| 3688 | 3686 |
struct in_src {
|
| 3689 | 3687 |
# define IS_TYPE_FP 1 |
| 3690 | 3688 |
# define IS_TYPE_BUF 2 |
| ... | ... |
@@ -3777,8 +3775,6 @@ check_inline_file_via_buf (struct buffer *multiline, char *p[], struct gc_arena |
| 3777 | 3777 |
return check_inline_file (&is, p, gc); |
| 3778 | 3778 |
} |
| 3779 | 3779 |
|
| 3780 |
-#endif |
|
| 3781 |
- |
|
| 3782 | 3780 |
static void |
| 3783 | 3781 |
add_option (struct options *options, |
| 3784 | 3782 |
char *p[], |
| ... | ... |
@@ -3824,9 +3820,7 @@ read_config_file (struct options *options, |
| 3824 | 3824 |
if (parse_line (line, p, SIZE (p), file, line_num, msglevel, &options->gc)) |
| 3825 | 3825 |
{
|
| 3826 | 3826 |
bypass_doubledash (&p[0]); |
| 3827 |
-#if ENABLE_INLINE_FILES |
|
| 3828 | 3827 |
check_inline_file_via_fp (fp, p, &options->gc); |
| 3829 |
-#endif |
|
| 3830 | 3828 |
add_option (options, p, file, line_num, level, msglevel, permission_mask, option_types_found, es); |
| 3831 | 3829 |
} |
| 3832 | 3830 |
} |
| ... | ... |
@@ -3869,9 +3863,7 @@ read_config_string (const char *prefix, |
| 3869 | 3869 |
if (parse_line (line, p, SIZE (p), prefix, line_num, msglevel, &options->gc)) |
| 3870 | 3870 |
{
|
| 3871 | 3871 |
bypass_doubledash (&p[0]); |
| 3872 |
-#if ENABLE_INLINE_FILES |
|
| 3873 | 3872 |
check_inline_file_via_buf (&multiline, p, &options->gc); |
| 3874 |
-#endif |
|
| 3875 | 3873 |
add_option (options, p, NULL, line_num, 0, msglevel, permission_mask, option_types_found, es); |
| 3876 | 3874 |
} |
| 3877 | 3875 |
CLEAR (p); |
| ... | ... |
@@ -6270,13 +6262,11 @@ add_option (struct options *options, |
| 6270 | 6270 |
else if (streq (p[0], "secret") && p[1]) |
| 6271 | 6271 |
{
|
| 6272 | 6272 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6273 |
-#if ENABLE_INLINE_FILES |
|
| 6274 | 6273 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6275 | 6274 |
{
|
| 6276 | 6275 |
options->shared_secret_file_inline = p[2]; |
| 6277 | 6276 |
} |
| 6278 | 6277 |
else |
| 6279 |
-#endif |
|
| 6280 | 6278 |
if (p[2]) |
| 6281 | 6279 |
{
|
| 6282 | 6280 |
int key_direction; |
| ... | ... |
@@ -6467,12 +6457,10 @@ add_option (struct options *options, |
| 6467 | 6467 |
{
|
| 6468 | 6468 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6469 | 6469 |
options->ca_file = p[1]; |
| 6470 |
-#if ENABLE_INLINE_FILES |
|
| 6471 | 6470 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6472 | 6471 |
{
|
| 6473 | 6472 |
options->ca_file_inline = p[2]; |
| 6474 | 6473 |
} |
| 6475 |
-#endif |
|
| 6476 | 6474 |
} |
| 6477 | 6475 |
#ifndef ENABLE_CRYPTO_POLARSSL |
| 6478 | 6476 |
else if (streq (p[0], "capath") && p[1]) |
| ... | ... |
@@ -6485,34 +6473,28 @@ add_option (struct options *options, |
| 6485 | 6485 |
{
|
| 6486 | 6486 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6487 | 6487 |
options->dh_file = p[1]; |
| 6488 |
-#if ENABLE_INLINE_FILES |
|
| 6489 | 6488 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6490 | 6489 |
{
|
| 6491 | 6490 |
options->dh_file_inline = p[2]; |
| 6492 | 6491 |
} |
| 6493 |
-#endif |
|
| 6494 | 6492 |
} |
| 6495 | 6493 |
else if (streq (p[0], "cert") && p[1]) |
| 6496 | 6494 |
{
|
| 6497 | 6495 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6498 | 6496 |
options->cert_file = p[1]; |
| 6499 |
-#if ENABLE_INLINE_FILES |
|
| 6500 | 6497 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6501 | 6498 |
{
|
| 6502 | 6499 |
options->cert_file_inline = p[2]; |
| 6503 | 6500 |
} |
| 6504 |
-#endif |
|
| 6505 | 6501 |
} |
| 6506 | 6502 |
else if (streq (p[0], "extra-certs") && p[1]) |
| 6507 | 6503 |
{
|
| 6508 | 6504 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6509 | 6505 |
options->extra_certs_file = p[1]; |
| 6510 |
-#if ENABLE_INLINE_FILES |
|
| 6511 | 6506 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6512 | 6507 |
{
|
| 6513 | 6508 |
options->extra_certs_file_inline = p[2]; |
| 6514 | 6509 |
} |
| 6515 |
-#endif |
|
| 6516 | 6510 |
} |
| 6517 | 6511 |
else if (streq (p[0], "verify-hash") && p[1]) |
| 6518 | 6512 |
{
|
| ... | ... |
@@ -6530,24 +6512,20 @@ add_option (struct options *options, |
| 6530 | 6530 |
{
|
| 6531 | 6531 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6532 | 6532 |
options->priv_key_file = p[1]; |
| 6533 |
-#if ENABLE_INLINE_FILES |
|
| 6534 | 6533 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6535 | 6534 |
{
|
| 6536 | 6535 |
options->priv_key_file_inline = p[2]; |
| 6537 | 6536 |
} |
| 6538 |
-#endif |
|
| 6539 | 6537 |
} |
| 6540 | 6538 |
#ifndef ENABLE_CRYPTO_POLARSSL |
| 6541 | 6539 |
else if (streq (p[0], "pkcs12") && p[1]) |
| 6542 | 6540 |
{
|
| 6543 | 6541 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6544 | 6542 |
options->pkcs12_file = p[1]; |
| 6545 |
-#if ENABLE_INLINE_FILES |
|
| 6546 | 6543 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6547 | 6544 |
{
|
| 6548 | 6545 |
options->pkcs12_file_inline = p[2]; |
| 6549 | 6546 |
} |
| 6550 |
-#endif |
|
| 6551 | 6547 |
} |
| 6552 | 6548 |
#endif /* ENABLE_CRYPTO_POLARSSL */ |
| 6553 | 6549 |
else if (streq (p[0], "askpass")) |
| ... | ... |
@@ -6708,13 +6686,11 @@ add_option (struct options *options, |
| 6708 | 6708 |
else if (streq (p[0], "tls-auth") && p[1]) |
| 6709 | 6709 |
{
|
| 6710 | 6710 |
VERIFY_PERMISSION (OPT_P_GENERAL); |
| 6711 |
-#if ENABLE_INLINE_FILES |
|
| 6712 | 6711 |
if (streq (p[1], INLINE_FILE_TAG) && p[2]) |
| 6713 | 6712 |
{
|
| 6714 | 6713 |
options->tls_auth_file_inline = p[2]; |
| 6715 | 6714 |
} |
| 6716 | 6715 |
else |
| 6717 |
-#endif |
|
| 6718 | 6716 |
if (p[2]) |
| 6719 | 6717 |
{
|
| 6720 | 6718 |
int key_direction; |
| ... | ... |
@@ -498,9 +498,7 @@ struct options |
| 498 | 498 |
#ifdef ENABLE_CRYPTO |
| 499 | 499 |
/* Cipher parms */ |
| 500 | 500 |
const char *shared_secret_file; |
| 501 |
-#if ENABLE_INLINE_FILES |
|
| 502 | 501 |
const char *shared_secret_file_inline; |
| 503 |
-#endif |
|
| 504 | 502 |
int key_direction; |
| 505 | 503 |
bool ciphername_defined; |
| 506 | 504 |
const char *ciphername; |
| ... | ... |
@@ -538,14 +536,12 @@ struct options |
| 538 | 538 |
const char *tls_remote; |
| 539 | 539 |
const char *crl_file; |
| 540 | 540 |
|
| 541 |
-#if ENABLE_INLINE_FILES |
|
| 542 | 541 |
const char *ca_file_inline; |
| 543 | 542 |
const char *cert_file_inline; |
| 544 | 543 |
const char *extra_certs_file_inline; |
| 545 | 544 |
char *priv_key_file_inline; |
| 546 | 545 |
const char *dh_file_inline; |
| 547 | 546 |
const char *pkcs12_file_inline; /* contains the base64 encoding of pkcs12 file */ |
| 548 |
-#endif |
|
| 549 | 547 |
|
| 550 | 548 |
int ns_cert_type; /* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */ |
| 551 | 549 |
unsigned remote_cert_ku[MAX_PARMS]; |
| ... | ... |
@@ -592,9 +588,7 @@ struct options |
| 592 | 592 |
|
| 593 | 593 |
/* Special authentication MAC for TLS control channel */ |
| 594 | 594 |
const char *tls_auth_file; /* shared secret */ |
| 595 |
-#if ENABLE_INLINE_FILES |
|
| 596 | 595 |
const char *tls_auth_file_inline; |
| 597 |
-#endif |
|
| 598 | 596 |
|
| 599 | 597 |
/* Allow only one session */ |
| 600 | 598 |
bool single_session; |
| ... | ... |
@@ -138,11 +138,8 @@ void tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers); |
| 138 | 138 |
* "[[INLINE]]" in the case of inline files. |
| 139 | 139 |
* @param dh_file_inline A string containing the parameters |
| 140 | 140 |
*/ |
| 141 |
-void tls_ctx_load_dh_params(struct tls_root_ctx *ctx, const char *dh_file |
|
| 142 |
-#if ENABLE_INLINE_FILES |
|
| 143 |
- , const char *dh_file_inline |
|
| 144 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 145 |
- ); |
|
| 141 |
+void tls_ctx_load_dh_params(struct tls_root_ctx *ctx, const char *dh_file, |
|
| 142 |
+ const char *dh_file_inline); |
|
| 146 | 143 |
|
| 147 | 144 |
/** |
| 148 | 145 |
* Load PKCS #12 file for key, cert and (optionally) CA certs, and add to |
| ... | ... |
@@ -157,10 +154,7 @@ void tls_ctx_load_dh_params(struct tls_root_ctx *ctx, const char *dh_file |
| 157 | 157 |
* successful. |
| 158 | 158 |
*/ |
| 159 | 159 |
int tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file, |
| 160 |
-#if ENABLE_INLINE_FILES |
|
| 161 |
- const char *pkcs12_file_inline, |
|
| 162 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 163 |
- bool load_ca_file |
|
| 160 |
+ const char *pkcs12_file_inline, bool load_ca_file |
|
| 164 | 161 |
); |
| 165 | 162 |
|
| 166 | 163 |
/** |
| ... | ... |
@@ -190,10 +184,7 @@ void tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert |
| 190 | 190 |
* *x509 must be NULL. |
| 191 | 191 |
*/ |
| 192 | 192 |
void tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, |
| 193 |
-#if ENABLE_INLINE_FILES |
|
| 194 |
- const char *cert_file_inline, |
|
| 195 |
-#endif |
|
| 196 |
- openvpn_x509_cert_t **x509 |
|
| 193 |
+ const char *cert_file_inline, openvpn_x509_cert_t **x509 |
|
| 197 | 194 |
); |
| 198 | 195 |
|
| 199 | 196 |
/** |
| ... | ... |
@@ -214,10 +205,8 @@ void tls_ctx_free_cert_file (openvpn_x509_cert_t *x509); |
| 214 | 214 |
* @return 1 if an error occurred, 0 if parsing was |
| 215 | 215 |
* successful. |
| 216 | 216 |
*/ |
| 217 |
-int tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file |
|
| 218 |
-#if ENABLE_INLINE_FILES |
|
| 219 |
- , const char *priv_key_file_inline |
|
| 220 |
-#endif |
|
| 217 |
+int tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file, |
|
| 218 |
+ const char *priv_key_file_inline |
|
| 221 | 219 |
); |
| 222 | 220 |
|
| 223 | 221 |
#ifdef MANAGMENT_EXTERNAL_KEY |
| ... | ... |
@@ -234,9 +223,9 @@ int tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file |
| 234 | 234 |
* successful. |
| 235 | 235 |
*/ |
| 236 | 236 |
int tls_ctx_use_external_private_key (struct tls_root_ctx *ctx, openvpn_x509_cert_t *cert); |
| 237 |
- |
|
| 238 | 237 |
#endif |
| 239 | 238 |
|
| 239 |
+ |
|
| 240 | 240 |
/** |
| 241 | 241 |
* Load certificate authority certificates from the given file or path. |
| 242 | 242 |
* |
| ... | ... |
@@ -249,10 +238,7 @@ int tls_ctx_use_external_private_key (struct tls_root_ctx *ctx, openvpn_x509_cer |
| 249 | 249 |
* @param ca_path The path to load the CAs from |
| 250 | 250 |
*/ |
| 251 | 251 |
void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 252 |
-#if ENABLE_INLINE_FILES |
|
| 253 |
- const char *ca_file_inline, |
|
| 254 |
-#endif |
|
| 255 |
- const char *ca_path, bool tls_server |
|
| 252 |
+ const char *ca_file_inline, const char *ca_path, bool tls_server |
|
| 256 | 253 |
); |
| 257 | 254 |
|
| 258 | 255 |
/** |
| ... | ... |
@@ -266,10 +252,8 @@ void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 266 | 266 |
* "[[INLINE]]" in the case of inline files. |
| 267 | 267 |
* @param extra_certs_file_inline A string containing the certs |
| 268 | 268 |
*/ |
| 269 |
-void tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file |
|
| 270 |
-#if ENABLE_INLINE_FILES |
|
| 271 |
- , const char *extra_certs_file_inline |
|
| 272 |
-#endif |
|
| 269 |
+void tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file, |
|
| 270 |
+ const char *extra_certs_file_inline |
|
| 273 | 271 |
); |
| 274 | 272 |
|
| 275 | 273 |
#ifdef ENABLE_CRYPTO_POLARSSL |
| ... | ... |
@@ -209,10 +209,8 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers) |
| 209 | 209 |
} |
| 210 | 210 |
|
| 211 | 211 |
void |
| 212 |
-tls_ctx_load_dh_params (struct tls_root_ctx *ctx, const char *dh_file |
|
| 213 |
-#if ENABLE_INLINE_FILES |
|
| 214 |
- , const char *dh_file_inline |
|
| 215 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 212 |
+tls_ctx_load_dh_params (struct tls_root_ctx *ctx, const char *dh_file, |
|
| 213 |
+ const char *dh_file_inline |
|
| 216 | 214 |
) |
| 217 | 215 |
{
|
| 218 | 216 |
DH *dh; |
| ... | ... |
@@ -220,14 +218,12 @@ tls_ctx_load_dh_params (struct tls_root_ctx *ctx, const char *dh_file |
| 220 | 220 |
|
| 221 | 221 |
ASSERT(NULL != ctx); |
| 222 | 222 |
|
| 223 |
-#if ENABLE_INLINE_FILES |
|
| 224 | 223 |
if (!strcmp (dh_file, INLINE_FILE_TAG) && dh_file_inline) |
| 225 | 224 |
{
|
| 226 | 225 |
if (!(bio = BIO_new_mem_buf ((char *)dh_file_inline, -1))) |
| 227 | 226 |
msg (M_SSLERR, "Cannot open memory BIO for inline DH parameters"); |
| 228 | 227 |
} |
| 229 | 228 |
else |
| 230 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 231 | 229 |
{
|
| 232 | 230 |
/* Get Diffie Hellman Parameters */ |
| 233 | 231 |
if (!(bio = BIO_new_file (dh_file, "r"))) |
| ... | ... |
@@ -250,9 +246,7 @@ tls_ctx_load_dh_params (struct tls_root_ctx *ctx, const char *dh_file |
| 250 | 250 |
|
| 251 | 251 |
int |
| 252 | 252 |
tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file, |
| 253 |
-#if ENABLE_INLINE_FILES |
|
| 254 | 253 |
const char *pkcs12_file_inline, |
| 255 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 256 | 254 |
bool load_ca_file |
| 257 | 255 |
) |
| 258 | 256 |
{
|
| ... | ... |
@@ -266,7 +260,6 @@ tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file, |
| 266 | 266 |
|
| 267 | 267 |
ASSERT(NULL != ctx); |
| 268 | 268 |
|
| 269 |
-#if ENABLE_INLINE_FILES |
|
| 270 | 269 |
if (!strcmp (pkcs12_file, INLINE_FILE_TAG) && pkcs12_file_inline) |
| 271 | 270 |
{
|
| 272 | 271 |
BIO *b64 = BIO_new(BIO_f_base64()); |
| ... | ... |
@@ -281,7 +274,6 @@ tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file, |
| 281 | 281 |
BIO_free(bio); |
| 282 | 282 |
} |
| 283 | 283 |
else |
| 284 |
-#endif |
|
| 285 | 284 |
{
|
| 286 | 285 |
/* Load the PKCS #12 file */ |
| 287 | 286 |
if (!(fp = platform_fopen(pkcs12_file, "rb"))) |
| ... | ... |
@@ -371,10 +363,7 @@ tls_ctx_add_extra_certs (struct tls_root_ctx *ctx, BIO *bio) |
| 371 | 371 |
|
| 372 | 372 |
void |
| 373 | 373 |
tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, |
| 374 |
-#if ENABLE_INLINE_FILES |
|
| 375 |
- const char *cert_file_inline, |
|
| 376 |
-#endif |
|
| 377 |
- X509 **x509 |
|
| 374 |
+ const char *cert_file_inline, X509 **x509 |
|
| 378 | 375 |
) |
| 379 | 376 |
{
|
| 380 | 377 |
BIO *in = NULL; |
| ... | ... |
@@ -386,13 +375,11 @@ tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, |
| 386 | 386 |
if (NULL != x509) |
| 387 | 387 |
ASSERT (NULL == *x509); |
| 388 | 388 |
|
| 389 |
-#if ENABLE_INLINE_FILES |
|
| 390 | 389 |
inline_file = (strcmp (cert_file, INLINE_FILE_TAG) == 0); |
| 391 | 390 |
|
| 392 | 391 |
if (inline_file && cert_file_inline) |
| 393 | 392 |
in = BIO_new_mem_buf ((char *)cert_file_inline, -1); |
| 394 | 393 |
else |
| 395 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 396 | 394 |
in = BIO_new_file (cert_file, "r"); |
| 397 | 395 |
|
| 398 | 396 |
if (in == NULL) |
| ... | ... |
@@ -437,10 +424,8 @@ tls_ctx_free_cert_file (X509 *x509) |
| 437 | 437 |
} |
| 438 | 438 |
|
| 439 | 439 |
int |
| 440 |
-tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file |
|
| 441 |
-#if ENABLE_INLINE_FILES |
|
| 442 |
- , const char *priv_key_file_inline |
|
| 443 |
-#endif |
|
| 440 |
+tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file, |
|
| 441 |
+ const char *priv_key_file_inline |
|
| 444 | 442 |
) |
| 445 | 443 |
{
|
| 446 | 444 |
int status; |
| ... | ... |
@@ -453,11 +438,9 @@ tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file |
| 453 | 453 |
|
| 454 | 454 |
ssl_ctx = ctx->ctx; |
| 455 | 455 |
|
| 456 |
-#if ENABLE_INLINE_FILES |
|
| 457 | 456 |
if (!strcmp (priv_key_file, INLINE_FILE_TAG) && priv_key_file_inline) |
| 458 | 457 |
in = BIO_new_mem_buf ((char *)priv_key_file_inline, -1); |
| 459 | 458 |
else |
| 460 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 461 | 459 |
in = BIO_new_file (priv_key_file, "r"); |
| 462 | 460 |
|
| 463 | 461 |
if (!in) |
| ... | ... |
@@ -639,9 +622,7 @@ sk_x509_name_cmp(const X509_NAME * const *a, const X509_NAME * const *b) |
| 639 | 639 |
|
| 640 | 640 |
void |
| 641 | 641 |
tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 642 |
-#if ENABLE_INLINE_FILES |
|
| 643 | 642 |
const char *ca_file_inline, |
| 644 |
-#endif |
|
| 645 | 643 |
const char *ca_path, bool tls_server |
| 646 | 644 |
) |
| 647 | 645 |
{
|
| ... | ... |
@@ -662,11 +643,9 @@ tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 662 | 662 |
/* Try to add certificates and CRLs from ca_file */ |
| 663 | 663 |
if (ca_file) |
| 664 | 664 |
{
|
| 665 |
-#if ENABLE_INLINE_FILES |
|
| 666 | 665 |
if (!strcmp (ca_file, INLINE_FILE_TAG) && ca_file_inline) |
| 667 | 666 |
in = BIO_new_mem_buf ((char *)ca_file_inline, -1); |
| 668 | 667 |
else |
| 669 |
-#endif |
|
| 670 | 668 |
in = BIO_new_file (ca_file, "r"); |
| 671 | 669 |
|
| 672 | 670 |
if (in) |
| ... | ... |
@@ -739,18 +718,14 @@ tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 739 | 739 |
} |
| 740 | 740 |
|
| 741 | 741 |
void |
| 742 |
-tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file |
|
| 743 |
-#if ENABLE_INLINE_FILES |
|
| 744 |
- , const char *extra_certs_file_inline |
|
| 745 |
-#endif |
|
| 742 |
+tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file, |
|
| 743 |
+ const char *extra_certs_file_inline |
|
| 746 | 744 |
) |
| 747 | 745 |
{
|
| 748 | 746 |
BIO *in; |
| 749 |
-#if ENABLE_INLINE_FILES |
|
| 750 | 747 |
if (!strcmp (extra_certs_file, INLINE_FILE_TAG) && extra_certs_file_inline) |
| 751 | 748 |
in = BIO_new_mem_buf ((char *)extra_certs_file_inline, -1); |
| 752 | 749 |
else |
| 753 |
-#endif |
|
| 754 | 750 |
in = BIO_new_file (extra_certs_file, "r"); |
| 755 | 751 |
|
| 756 | 752 |
if (in == NULL) |
| ... | ... |
@@ -195,20 +195,16 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers) |
| 195 | 195 |
} |
| 196 | 196 |
|
| 197 | 197 |
void |
| 198 |
-tls_ctx_load_dh_params (struct tls_root_ctx *ctx, const char *dh_file |
|
| 199 |
-#if ENABLE_INLINE_FILES |
|
| 200 |
- , const char *dh_file_inline |
|
| 201 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 198 |
+tls_ctx_load_dh_params (struct tls_root_ctx *ctx, const char *dh_file, |
|
| 199 |
+ const char *dh_file_inline |
|
| 202 | 200 |
) |
| 203 | 201 |
{
|
| 204 |
-#if ENABLE_INLINE_FILES |
|
| 205 | 202 |
if (!strcmp (dh_file, INLINE_FILE_TAG) && dh_file_inline) |
| 206 | 203 |
{
|
| 207 | 204 |
if (0 != x509parse_dhm(ctx->dhm_ctx, dh_file_inline, strlen(dh_file_inline))) |
| 208 | 205 |
msg (M_FATAL, "Cannot read inline DH parameters"); |
| 209 | 206 |
} |
| 210 | 207 |
else |
| 211 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 212 | 208 |
{
|
| 213 | 209 |
if (0 != x509parse_dhmfile(ctx->dhm_ctx, dh_file)) |
| 214 | 210 |
msg (M_FATAL, "Cannot read DH parameters from file %s", dh_file); |
| ... | ... |
@@ -220,9 +216,7 @@ else |
| 220 | 220 |
|
| 221 | 221 |
int |
| 222 | 222 |
tls_ctx_load_pkcs12(struct tls_root_ctx *ctx, const char *pkcs12_file, |
| 223 |
-#if ENABLE_INLINE_FILES |
|
| 224 | 223 |
const char *pkcs12_file_inline, |
| 225 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 226 | 224 |
bool load_ca_file |
| 227 | 225 |
) |
| 228 | 226 |
{
|
| ... | ... |
@@ -240,9 +234,7 @@ tls_ctx_load_cryptoapi(struct tls_root_ctx *ctx, const char *cryptoapi_cert) |
| 240 | 240 |
|
| 241 | 241 |
void |
| 242 | 242 |
tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, |
| 243 |
-#if ENABLE_INLINE_FILES |
|
| 244 | 243 |
const char *cert_file_inline, |
| 245 |
-#endif |
|
| 246 | 244 |
openvpn_x509_cert_t **x509 |
| 247 | 245 |
) |
| 248 | 246 |
{
|
| ... | ... |
@@ -250,7 +242,6 @@ tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, |
| 250 | 250 |
if (NULL != x509) |
| 251 | 251 |
ASSERT(NULL == *x509); |
| 252 | 252 |
|
| 253 |
-#if ENABLE_INLINE_FILES |
|
| 254 | 253 |
if (!strcmp (cert_file, INLINE_FILE_TAG) && cert_file_inline) |
| 255 | 254 |
{
|
| 256 | 255 |
if (0 != x509parse_crt(ctx->crt_chain, cert_file_inline, |
| ... | ... |
@@ -258,7 +249,6 @@ tls_ctx_load_cert_file (struct tls_root_ctx *ctx, const char *cert_file, |
| 258 | 258 |
msg (M_FATAL, "Cannot load inline certificate file"); |
| 259 | 259 |
} |
| 260 | 260 |
else |
| 261 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 262 | 261 |
{
|
| 263 | 262 |
if (0 != x509parse_crtfile(ctx->crt_chain, cert_file)) |
| 264 | 263 |
msg (M_FATAL, "Cannot load certificate file %s", cert_file); |
| ... | ... |
@@ -276,16 +266,13 @@ tls_ctx_free_cert_file (openvpn_x509_cert_t *x509) |
| 276 | 276 |
} |
| 277 | 277 |
|
| 278 | 278 |
int |
| 279 |
-tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file |
|
| 280 |
-#if ENABLE_INLINE_FILES |
|
| 281 |
- , const char *priv_key_file_inline |
|
| 282 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 279 |
+tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file, |
|
| 280 |
+ const char *priv_key_file_inline |
|
| 283 | 281 |
) |
| 284 | 282 |
{
|
| 285 | 283 |
int status; |
| 286 | 284 |
ASSERT(NULL != ctx); |
| 287 | 285 |
|
| 288 |
-#if ENABLE_INLINE_FILES |
|
| 289 | 286 |
if (!strcmp (priv_key_file, INLINE_FILE_TAG) && priv_key_file_inline) |
| 290 | 287 |
{
|
| 291 | 288 |
status = x509parse_key(ctx->priv_key, |
| ... | ... |
@@ -301,7 +288,6 @@ tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file |
| 301 | 301 |
} |
| 302 | 302 |
} |
| 303 | 303 |
else |
| 304 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 305 | 304 |
{
|
| 306 | 305 |
status = x509parse_keyfile(ctx->priv_key, priv_key_file, NULL); |
| 307 | 306 |
if (POLARSSL_ERR_PEM_PASSWORD_REQUIRED == status) |
| ... | ... |
@@ -343,23 +329,19 @@ tls_ctx_use_external_private_key (struct tls_root_ctx *ctx, openvpn_x509_cert_t |
| 343 | 343 |
#endif |
| 344 | 344 |
|
| 345 | 345 |
void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 346 |
-#if ENABLE_INLINE_FILES |
|
| 347 | 346 |
const char *ca_file_inline, |
| 348 |
-#endif |
|
| 349 | 347 |
const char *ca_path, bool tls_server |
| 350 | 348 |
) |
| 351 | 349 |
{
|
| 352 | 350 |
if (ca_path) |
| 353 | 351 |
msg(M_FATAL, "ERROR: PolarSSL cannot handle the capath directive"); |
| 354 | 352 |
|
| 355 |
-#if ENABLE_INLINE_FILES |
|
| 356 | 353 |
if (ca_file && !strcmp (ca_file, INLINE_FILE_TAG) && ca_file_inline) |
| 357 | 354 |
{
|
| 358 | 355 |
if (0 != x509parse_crt(ctx->ca_chain, ca_file_inline, strlen(ca_file_inline))); |
| 359 | 356 |
msg (M_FATAL, "Cannot load inline CA certificates"); |
| 360 | 357 |
} |
| 361 | 358 |
else |
| 362 |
-#endif |
|
| 363 | 359 |
{
|
| 364 | 360 |
/* Load CA file for verifying peer supplied certificate */ |
| 365 | 361 |
if (0 != x509parse_crtfile(ctx->ca_chain, ca_file)) |
| ... | ... |
@@ -368,15 +350,12 @@ void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file, |
| 368 | 368 |
} |
| 369 | 369 |
|
| 370 | 370 |
void |
| 371 |
-tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file |
|
| 372 |
-#if ENABLE_INLINE_FILES |
|
| 373 |
- , const char *extra_certs_file_inline |
|
| 374 |
-#endif |
|
| 371 |
+tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file, |
|
| 372 |
+ const char *extra_certs_file_inline |
|
| 375 | 373 |
) |
| 376 | 374 |
{
|
| 377 | 375 |
ASSERT(NULL != ctx); |
| 378 | 376 |
|
| 379 |
-#if ENABLE_INLINE_FILES |
|
| 380 | 377 |
if (!strcmp (extra_certs_file, INLINE_FILE_TAG) && extra_certs_file_inline) |
| 381 | 378 |
{
|
| 382 | 379 |
if (0 != x509parse_crt(ctx->crt_chain, extra_certs_file_inline, |
| ... | ... |
@@ -384,7 +363,6 @@ tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file |
| 384 | 384 |
msg (M_FATAL, "Cannot load inline extra-certs file"); |
| 385 | 385 |
} |
| 386 | 386 |
else |
| 387 |
-#endif /* ENABLE_INLINE_FILES */ |
|
| 388 | 387 |
{
|
| 389 | 388 |
if (0 != x509parse_crtfile(ctx->crt_chain, extra_certs_file)) |
| 390 | 389 |
msg (M_FATAL, "Cannot load extra-certs file: %s", extra_certs_file); |
| ... | ... |
@@ -650,17 +650,9 @@ socket_defined (const socket_descriptor_t sd) |
| 650 | 650 |
#endif |
| 651 | 651 |
|
| 652 | 652 |
/* |
| 653 |
- * Should we allow ca/cert/key files to be |
|
| 654 |
- * included inline, in the configuration file? |
|
| 655 |
- */ |
|
| 656 |
-#define ENABLE_INLINE_FILES 1 |
|
| 657 |
- |
|
| 658 |
-/* |
|
| 659 | 653 |
* Support "connection" directive |
| 660 | 654 |
*/ |
| 661 |
-#if ENABLE_INLINE_FILES |
|
| 662 | 655 |
#define ENABLE_CONNECTION 1 |
| 663 |
-#endif |
|
| 664 | 656 |
|
| 665 | 657 |
/* |
| 666 | 658 |
* Should we include http proxy fallback functionality |