Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add trust-all-certs option. #727

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const struct vpn_config invalid_cfg = {
.user_cert = NULL,
.user_key = NULL,
.insecure_ssl = -1,
.trust_all_certs = -1,
.cipher_list = NULL,
.min_tls = -1,
.seclevel_1 = -1,
Expand Down Expand Up @@ -402,6 +403,15 @@ int load_config(struct vpn_config *cfg, const char *filename)
continue;
}
cfg->insecure_ssl = insecure_ssl;
} else if (strcmp(key, "trust-all-certs") == 0) {
int trust_all_certs = strtob(val);

if (trust_all_certs < 0) {
log_warn("Bad trust-all-certs in config file: \"%s\".\n",
val);
continue;
}
cfg->trust_all_certs = trust_all_certs;
} else if (strcmp(key, "cipher-list") == 0) {
free(cfg->cipher_list);
cfg->cipher_list = strdup(val);
Expand Down Expand Up @@ -550,6 +560,8 @@ void merge_config(struct vpn_config *dst, struct vpn_config *src)
}
if (src->insecure_ssl != invalid_cfg.insecure_ssl)
dst->insecure_ssl = src->insecure_ssl;
if (src->trust_all_certs != invalid_cfg.trust_all_certs)
dst->trust_all_certs = src->trust_all_certs;
if (src->cipher_list) {
free(dst->cipher_list);
dst->cipher_list = src->cipher_list;
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ struct vpn_config {
char *user_cert;
char *user_key;
int insecure_ssl;
int trust_all_certs;
int min_tls;
int seclevel_1;
char *cipher_list;
Expand Down
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ PPPD_USAGE \
" Also enable TLS v1.0 if applicable.\n" \
" If your server requires a specific cipher or protocol,\n" \
" consider using --cipher-list and/or --min-tls instead.\n" \
" --trust-all-certs Trust all gateway certificates.\n" \
" --cipher-list=<ciphers> OpenSSL ciphers to use. If default does not work\n" \
" you can try with the cipher suggested in the output\n" \
" of 'openssl s_client -connect <host:port>'\n" \
Expand Down Expand Up @@ -222,6 +223,7 @@ int main(int argc, char **argv)
.user_cert = NULL,
.user_key = NULL,
.insecure_ssl = 0,
.trust_all_certs = 0,
#ifdef TLS1_2_VERSION
.min_tls = TLS1_2_VERSION,
#else
Expand Down Expand Up @@ -257,6 +259,7 @@ int main(int argc, char **argv)
{"user-key", required_argument, NULL, 0},
{"trusted-cert", required_argument, NULL, 0},
{"insecure-ssl", no_argument, &cli_cfg.insecure_ssl, 1},
{"trust-all-certs", no_argument, &cli_cfg.trust_all_certs, 1 },
{"cipher-list", required_argument, NULL, 0},
{"min-tls", required_argument, NULL, 0},
{"seclevel-1", no_argument, &cli_cfg.seclevel_1, 1},
Expand Down
6 changes: 6 additions & 0 deletions src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,12 @@ static int ssl_verify_cert(struct tunnel *tunnel)
for (i = 0; i < SHA256LEN; i++)
sprintf(&digest_str[2 * i], "%02x", digest[i]);
digest_str[SHA256STRLEN - 1] = '\0';
// Do we trust all certificates?
if (tunnel->config->trust_all_certs > 0) {
log_debug("Trusted gateway certificate digest: %s\n", digest_str);
ret = 0;
goto free_cert;
}
// Is it in whitelist?
for (elem = tunnel->config->cert_whitelist; elem != NULL;
elem = elem->next)
Expand Down