Skip to content

Commit

Permalink
Reuse old SSL key if loading a new one failed
Browse files Browse the repository at this point in the history
  • Loading branch information
michi authored and alexbarton committed Feb 15, 2020
1 parent c411643 commit e7cb9b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/ngircd/conn-ssl.c
Expand Up @@ -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\"!",
Expand Down
2 changes: 1 addition & 1 deletion src/ngircd/sighandlers.c
Expand Up @@ -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( );
Expand Down

0 comments on commit e7cb9b1

Please sign in to comment.