]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_crypto.c
* cleanup ourselfs on exit.
[citadel.git] / citadel / serv_crypto.c
index 38e828bb9c8b6a6a234bb2c204bf69dae5725a08..0db01ac47b8fdcd0bb8dafadf63f87bf65c2c1e0 100644 (file)
@@ -49,6 +49,16 @@ static unsigned long id_callback(void)
        return (unsigned long) pthread_self();
 }
 
+void destruct_ssl(void)
+{
+       int a;
+       CtdlUnregisterProtoHook(cmd_stls, "STLS");
+       CtdlUnregisterProtoHook(cmd_gtls, "GTLS");
+       for (a = 0; a < CRYPTO_num_locks(); a++) 
+               free(SSLCritters[a]);
+       free (SSLCritters);
+}
+
 void init_ssl(void)
 {
        SSL_METHOD *ssl_method;
@@ -147,7 +157,7 @@ void init_ssl(void)
        /* Get our certificates in order.
         * First, create the key/cert directory if it's not there already...
         */
-       mkdir(ctdl_ssl_dir, 0700);
+       mkdir(ctdl_key_dir, 0700);
 
        /*
         * Generate a key pair if we don't have one.
@@ -196,7 +206,7 @@ void init_ssl(void)
                 * there is the possibility that the key was already on disk
                 * and we didn't just generate it now.
                 */
-               fp = fopen(file_crpt_file_csr, "r");
+               fp = fopen(file_crpt_file_key, "r");
                if (fp) {
                        rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL);
                        fclose(fp);
@@ -280,7 +290,7 @@ void init_ssl(void)
                /* Same deal as before: always read the key from disk because
                 * it may or may not have just been generated.
                 */
-               fp = fopen(file_crpt_file_cer, "r");
+               fp = fopen(file_crpt_file_key, "r");
                if (fp) {
                        rsa = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL);
                        fclose(fp);
@@ -295,7 +305,7 @@ void init_ssl(void)
                                EVP_PKEY_assign_RSA(pk, rsa);
                        }
 
-                       fp = fopen(file_crpt_file_cer, "r");
+                       fp = fopen(file_crpt_file_csr, "r");
                        if (fp) {
                                req = PEM_read_X509_REQ(fp, NULL, NULL, NULL);
                                fclose(fp);