]> code.citadel.org Git - citadel.git/blobdiff - webcit/crypto.c
Applied patch sent by Chris West to fix Debian bug 859789
[citadel.git] / webcit / crypto.c
index d7b460cdef1864651e515eba86b7230456ec94b2..6e350aee4f66ff151d7120110aae1a449c347355 100644 (file)
@@ -29,6 +29,8 @@ char *ssl_cipher_list = DEFAULT_SSL_CIPHER_LIST;
 
 pthread_key_t ThreadSSL;       /* Per-thread SSL context */
 
+void ssl_lock(int mode, int n, const char *file, int line);
+
 static unsigned long id_callback(void)
 {
        return (unsigned long) pthread_self();
@@ -63,9 +65,11 @@ void init_ssl(void)
        char buf[SIZ];
        int rv = 0;
 
+#ifndef OPENSSL_NO_EGD
        if (!access("/var/run/egd-pool", F_OK)) {
                RAND_egd("/var/run/egd-pool");
        }
+#endif
 
        if (!RAND_status()) {
                syslog(LOG_WARNING, "PRNG not adequately seeded, won't do SSL/TLS\n");
@@ -83,7 +87,7 @@ void init_ssl(void)
                for (a = 0; a < CRYPTO_num_locks(); a++) {
                        SSLCritters[a] = malloc(sizeof(pthread_mutex_t));
                        if (!SSLCritters[a]) {
-                               syslog(LOG_EMERG,
+                               syslog(LOG_ERR,
                                        "citserver: can't allocate memory!!\n");
                                /** Nothing's been initialized, just die */
                                ShutDownWebcit();
@@ -331,8 +335,8 @@ void init_ssl(void)
                                if (cer = X509_new(), cer != NULL) {
 
                                        ASN1_INTEGER_set(X509_get_serialNumber(cer), 0);
-                                       X509_set_issuer_name(cer, req->req_info->subject);
-                                       X509_set_subject_name(cer, req->req_info->subject);
+                                       X509_set_issuer_name(cer, X509_REQ_get_subject_name(req));
+                                       X509_set_subject_name(cer, X509_REQ_get_subject_name(req));
                                        X509_gmtime_adj(X509_get_notBefore(cer), 0);
                                        X509_gmtime_adj(X509_get_notAfter(cer),(long)60*60*24*SIGN_DAYS);
 
@@ -442,7 +446,7 @@ int starttls(int sock) {
        else {
                syslog(LOG_INFO, "SSL_accept success\n");
        }
-       /*r = */BIO_set_close(newssl->rbio, BIO_NOCLOSE);
+       /*r = */BIO_set_close(SSL_get_rbio(newssl), BIO_NOCLOSE);
        bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(newssl), &alg_bits);
        syslog(LOG_INFO, "SSL/TLS using %s on %s (%d of %d bits)\n",
                SSL_CIPHER_get_name(SSL_get_current_cipher(newssl)),
@@ -501,7 +505,7 @@ void ssl_lock(int mode, int n, const char *file, int line)
 /*
  * Send binary data to the client encrypted.
  */
-void client_write_ssl(const StrBuf *Buf)
+int client_write_ssl(const StrBuf *Buf)
 {
        const char *buf;
        int retval;
@@ -509,7 +513,7 @@ void client_write_ssl(const StrBuf *Buf)
        long nbytes;
        char junk[1];
 
-       if (THREADSSL == NULL) return;
+       if (THREADSSL == NULL) return -1;
 
        nbytes = nremain = StrLength(Buf);
        buf = ChrPtr(Buf);
@@ -535,10 +539,11 @@ void client_write_ssl(const StrBuf *Buf)
                                syslog(LOG_WARNING, "errno is %d\n", errno);
                        }
                        endtls();
-                       return;
+                       return -1;
                }
                nremain -= retval;
        }
+       return 0;
 }