Unified the openssl library initialization code
authorArt Cancro <ajc@citadel.org>
Mon, 10 Jan 2022 16:28:03 +0000 (11:28 -0500)
committerArt Cancro <ajc@citadel.org>
Mon, 10 Jan 2022 16:28:03 +0000 (11:28 -0500)
citadel/modules/crypto/serv_crypto.c
webcit-ng/tls.c
webcit/crypto.c
webcit/sysdep.c

index dcbab519ec2f01a8cb90ab932fcd7ab3d7ac16f2..310150af8f1d400a6041465757fc6871c51b98e8 100644 (file)
@@ -268,15 +268,20 @@ void update_key_and_cert_if_needed(void) {
 
 // Initialize the SSL/TLS subsystem.
 void init_ssl(void) {
-       SSL_library_init();                                             // Initialize SSL transport layer
+
+       // Initialize the OpenSSL library
        SSL_load_error_strings();
+       ERR_load_crypto_strings();
+       OpenSSL_add_all_algorithms();
+       SSL_library_init();
 
+       // Load (or generate) a key and certificate
        mkdir(ctdl_key_dir, 0700);                                      // If the keys directory does not exist, create it
        generate_key(file_crpt_file_key);                               // If a private key does not exist, create it
        generate_certificate(file_crpt_file_key, file_crpt_file_cer);   // If a certificate does not exist, create it
        bind_to_key_and_certificate();                                  // Load key and cert from disk, and bind to them.
 
-       // Finally let the server know we're here
+       // Register some Citadel protocol commands for dealing with encrypted sessions
        CtdlRegisterProtoHook(cmd_stls, "STLS", "Start SSL/TLS session");
        CtdlRegisterProtoHook(cmd_gtls, "GTLS", "Get SSL/TLS session status");
        CtdlRegisterSessionHook(endtls, EVT_STOP, PRIO_STOP + 10);
index 61ee44b0d1f9f3e8b7b43dccedf9ef0dcd7e288c..4a939a90084e35ea93dcea248fdd911f5bdb8460 100644 (file)
@@ -63,9 +63,11 @@ void bind_to_key_and_certificate(void) {
 // Initialize ssl engine, load certs and initialize openssl internals
 void init_ssl(void) {
 
-       // Initialize SSL transport layer
-       SSL_library_init();
+       // Initialize the OpenSSL library
        SSL_load_error_strings();
+       ERR_load_crypto_strings();
+       OpenSSL_add_all_algorithms();
+       SSL_library_init();
 
        // Now try to bind to the key and certificate.
        bind_to_key_and_certificate();
index 3d9b534692b3b667504b90c282361ac6a3922b1a..9f85b2ad9d135228b44d512d226de49e78a91f85 100644 (file)
@@ -22,10 +22,6 @@ char *ssl_cipher_list = DEFAULT_SSL_CIPHER_LIST;
 
 pthread_key_t ThreadSSL;       // Per-thread SSL context
 
-void shutdown_ssl(void) {
-       ERR_free_strings();
-}
-
 
 // Set the private key and certificate chain for the global SSL Context.
 // This is called during initialization, and can be called again later if the certificate changes.
@@ -70,9 +66,11 @@ void bind_to_key_and_certificate(void) {
 // initialize ssl engine, load certs and initialize openssl internals
 void init_ssl(void) {
 
-       // Initialize SSL transport layer
-       SSL_library_init();
+       // Initialize the OpenSSL library
        SSL_load_error_strings();
+       ERR_load_crypto_strings();
+       OpenSSL_add_all_algorithms();
+       SSL_library_init();
 
        // Now try to bind to the key and certificate.
        bind_to_key_and_certificate();
index 0c58118a0847a8abb035d3c870d814a073d9bf27..7c699699afb83939feddd2410f390111ff82ece5 100644 (file)
@@ -179,11 +179,6 @@ void ShutDownWebcit(void)
        icalmemory_free_ring ();
        ShutDownLibCitadel ();
        shutdown_modules ();
-#ifdef HAVE_OPENSSL
-       if (is_https) {
-               shutdown_ssl();
-       }
-#endif
 }
 
 /*