]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/crypto/serv_crypto.c
ssl_ctx = SSL_CTX_new(SSLv23_server_method()) instead of using a temporary variable...
[citadel.git] / citadel / modules / crypto / serv_crypto.c
index 98cded3c9f273364f227ffc1bd06ab14cd9e60f8..cbb190cde857e987a76c0b3a87a22622aec3ec9b 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 1987-2021 by the citadel.org team
+// Copyright (c) 1987-2022 by the citadel.org team
 //
 // This program is open source software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License version 3.
@@ -112,7 +112,7 @@ void bind_to_key_and_certificate(void) {
 
 // Check the modification time of the key and certificate -- reload if they changed
 void update_key_and_cert_if_needed(void) {
-       static time_t cert_mtime = 0;
+       static time_t previous_mtime = 0;
        struct stat keystat;
        struct stat certstat;
 
@@ -125,15 +125,14 @@ void update_key_and_cert_if_needed(void) {
                return;
        }
 
-       if ((keystat.st_mtime > cert_mtime) || (certstat.st_mtime > cert_mtime)) {
+       if ((keystat.st_mtime + certstat.st_mtime) != previous_mtime) {
                bind_to_key_and_certificate();
-               cert_mtime = certstat.st_mtime;
+               previous_mtime = keystat.st_mtime + certstat.st_mtime;
        }
 }
 
 
 void init_ssl(void) {
-       const SSL_METHOD *ssl_method;
        RSA *rsa = NULL;
        X509_REQ *req = NULL;
        X509 *cer = NULL;
@@ -145,8 +144,7 @@ void init_ssl(void) {
        // Initialize SSL transport layer
        SSL_library_init();
        SSL_load_error_strings();
-       ssl_method = SSLv23_server_method();
-       if (!(ssl_ctx = SSL_CTX_new(ssl_method))) {
+       if (!(ssl_ctx = SSL_CTX_new(SSLv23_server_method()))) {
                syslog(LOG_ERR, "crypto: SSL_CTX_new failed: %s", ERR_reason_error_string(ERR_get_error()));
                return;
        }