From: michi Date: Fri, 14 Feb 2020 12:44:10 +0000 (+0000) Subject: Reuse old SSL key if loading a new one failed X-Git-Tag: rel-26-rc1~47 X-Git-Url: https://arthur.barton.de/gitweb/?p=ngircd.git;a=commitdiff_plain;h=e7cb9b1a001a97b1edf0e862808cbd0be5264a7a;ds=sidebyside Reuse old SSL key if loading a new one failed --- diff --git a/src/ngircd/conn-ssl.c b/src/ngircd/conn-ssl.c index ba47e513..3f482dc7 100644 --- a/src/ngircd/conn-ssl.c +++ b/src/ngircd/conn-ssl.c @@ -311,8 +311,18 @@ ConnSSL_InitLibrary( void ) return false; } - if (!ConnSSL_LoadServerKey_openssl(newctx)) + if (!ConnSSL_LoadServerKey_openssl(newctx)) { + /* Failed to read new key but an old ssl context + * already exists -> reuse old context */ + if (ssl_ctx) { + SSL_CTX_free(newctx); + Log(LOG_WARNING, + "Re-Initializing of SSL failed, using old keys!"); + return true; + } + /* No preexisting old context -> error. */ goto out; + } if (SSL_CTX_set_cipher_list(newctx, Conf_SSLOptions.CipherList) == 0) { Log(LOG_ERR, "Failed to apply OpenSSL cipher list \"%s\"!", diff --git a/src/ngircd/sighandlers.c b/src/ngircd/sighandlers.c index f7ae4f45..8275123e 100644 --- a/src/ngircd/sighandlers.c +++ b/src/ngircd/sighandlers.c @@ -132,7 +132,7 @@ Rehash(void) if (!ConnSSL_InitLibrary()) Log(LOG_WARNING, - "Re-Initializing of SSL failed, using old keys!"); + "Re-Initializing of SSL failed!"); /* Start listening on sockets */ Conn_InitListeners( );