Skip to content

Commit 8320381

Browse files
committed
sudo_logsrvd: Exit with error if relay uses TLS but TLS is not configured.
1 parent dee6828 commit 8320381

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

logsrvd/logsrvd_conf.c

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,25 +1790,34 @@ logsrvd_conf_apply(struct logsrvd_config *config)
17901790
break;
17911791
}
17921792

1793-
if (TLS_CONFIGURED(config->relay)) {
1794-
TAILQ_FOREACH(addr, &config->relay.relays.addrs, entries) {
1795-
if (!addr->tls)
1796-
continue;
1797-
/* Create a TLS context for the relay. */
1798-
config->relay.ssl_ctx = init_tls_context(
1799-
TLS_RELAY_STR(config, tls_cacert_path),
1800-
TLS_RELAY_STR(config, tls_cert_path),
1801-
TLS_RELAY_STR(config, tls_key_path),
1802-
TLS_RELAY_STR(config, tls_dhparams_path),
1803-
TLS_RELAY_STR(config, tls_ciphers_v12),
1804-
TLS_RELAY_STR(config, tls_ciphers_v13),
1805-
TLS_RELAY_INT(config, tls_verify));
1806-
if (config->relay.ssl_ctx == NULL) {
1807-
sudo_warnx("%s", U_("unable to initialize relay TLS context"));
1808-
debug_return_bool(false);
1793+
TAILQ_FOREACH(addr, &config->relay.relays.addrs, entries) {
1794+
if (!addr->tls)
1795+
continue;
1796+
1797+
/* Relay requires TLS so it must be configured (in relay or server). */
1798+
if (!TLS_CONFIGURED(config->relay)) {
1799+
if (config->server.ssl_ctx != NULL) {
1800+
/* We will use the server TLS settings. */
1801+
break;
18091802
}
1810-
break;
1803+
sudo_warnx("%s", U_("relay uses TLS but TLS not configured"));
1804+
debug_return_bool(false);
1805+
}
1806+
1807+
/* Create a TLS context for the relay. */
1808+
config->relay.ssl_ctx = init_tls_context(
1809+
TLS_RELAY_STR(config, tls_cacert_path),
1810+
TLS_RELAY_STR(config, tls_cert_path),
1811+
TLS_RELAY_STR(config, tls_key_path),
1812+
TLS_RELAY_STR(config, tls_dhparams_path),
1813+
TLS_RELAY_STR(config, tls_ciphers_v12),
1814+
TLS_RELAY_STR(config, tls_ciphers_v13),
1815+
TLS_RELAY_INT(config, tls_verify));
1816+
if (config->relay.ssl_ctx == NULL) {
1817+
sudo_warnx("%s", U_("unable to initialize relay TLS context"));
1818+
debug_return_bool(false);
18111819
}
1820+
break;
18121821
}
18131822
#endif /* HAVE_OPENSSL */
18141823

0 commit comments

Comments
 (0)