Skip to content

Commit

Permalink
add config for DH-file
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Mauchle committed Aug 11, 2020
1 parent 440e3b8 commit a26f42e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ unreleased chanes
- Specify source per server
- User configurable cipher-list and ciphersuites
- User configurable TLS versions
- Config option for DH-file

Misc:
- Move radsecproxy manpage to section 8
Expand Down
4 changes: 4 additions & 0 deletions radsecproxy.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,11 @@ Currently supported values are
for TLS and
.BR DTLS1 , DTLS1_1
for DTLS.
.RE

.BI "DhFile " file
.RS
DH parameter \fIfile\fR to use. See \fBopenssl-dhparam\fR(1)


.SH "REWRITE BLOCK"
Expand Down
32 changes: 32 additions & 0 deletions tlscommon.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,14 @@ static SSL_CTX *tlscreatectx(uint8_t type, struct tls *conf) {
}
}
#endif

if (conf->dhparam) {
if (!SSL_CTX_set_tmp_dh(ctx, conf->dhparam)) {
while ((error = ERR_get_error()))
debug(DBG_WARN, "tlscreatectx: SSL: %s", ERR_error_string(error, NULL));
debug(DBG_WARN, "tlscreatectx: Failed to set dh params. Can continue, but some ciphers might not be available.");
}
}
debug(DBG_DBG, "tlscreatectx: created TLS context %s", conf->name);
return ctx;
}
Expand Down Expand Up @@ -823,6 +831,8 @@ int conftls_cb(struct gconffile **cf, void *arg, char *block, char *opt, char *v
long int expiry = LONG_MIN;
char *tlsversion = NULL;
char *dtlsversion = NULL;
char *dhfile = NULL;
unsigned long error;

debug(DBG_DBG, "conftls_cb called for %s", block);

Expand All @@ -846,6 +856,7 @@ int conftls_cb(struct gconffile **cf, void *arg, char *block, char *opt, char *v
"CipherSuites", CONF_STR, &conf->ciphersuites,
"TlsVersion", CONF_STR, &tlsversion,
"DtlsVersion", CONF_STR, &dtlsversion,
"DhFile", CONF_STR, &dhfile,
NULL
)) {
debug(DBG_ERR, "conftls_cb: configuration error in block %s", val);
Expand Down Expand Up @@ -889,6 +900,25 @@ int conftls_cb(struct gconffile **cf, void *arg, char *block, char *opt, char *v
goto errexit;
#endif

if (dhfile) {
FILE *dhfp = fopen(dhfile, "r");
if (dhfp) {
conf->dhparam = PEM_read_DHparams(dhfp, NULL, NULL, NULL);
fclose(dhfp);
if (!conf->dhparam) {
while ((error = ERR_get_error()))
debug(DBG_ERR, "SSL: %s", ERR_error_string(error, NULL));
debug(DBG_ERR, "error in block %s: Failed to load DhFile %s.", val, dhfile);
goto errexit;
}
} else {
debug(DBG_ERR, "error in block %s, DhFile: can't open file %s", val, dhfile);
goto errexit;
}
free(dhfile);
dhfile = NULL;
}

conf->name = stringcopy(val, 0);
if (!conf->name) {
debug(DBG_ERR, "conftls_cb: malloc failed");
Expand Down Expand Up @@ -916,6 +946,8 @@ int conftls_cb(struct gconffile **cf, void *arg, char *block, char *opt, char *v
freegconfmstr(conf->policyoids);
free(tlsversion);
free(dtlsversion);
free(dhfile);
DH_free(conf->dhparam);
free(conf);
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions tlscommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct tls {
int tlsmaxversion;
int dtlsminversion;
int dtlsmaxversion;
DH *dhparam;
uint32_t tlsexpiry;
uint32_t dtlsexpiry;
X509_VERIFY_PARAM *vpm;
Expand Down

0 comments on commit a26f42e

Please sign in to comment.