2006-04-06 [mones] 2.1.0cvs7
[claws.git] / src / common / ssl_certificate.c
index d37c62f4bea135e0a8554b4d24a0e57e2896fa19..ad5554a708942c6423b7753ee07a2fd62bf6e1eb 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * This file Copyright (C) 2002-2005 Colin Leroy <colin@colino.net>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -14,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -111,7 +112,7 @@ static void ssl_certificate_save (SSLCertificate *cert)
                          cert->host, ".", port, ".cert", NULL);
 
        g_free(port);
-       fp = fopen(file, "wb");
+       fp = g_fopen(file, "wb");
        if (fp == NULL) {
                g_free(file);
                debug_print("Can't save certificate !\n");
@@ -193,22 +194,14 @@ char* ssl_certificate_to_string(SSLCertificate *cert)
                                fingerprint,
                                (sig_status==NULL ? "correct":sig_status));
 
-       if (issuer_commonname)
-               g_free(issuer_commonname);
-       if (issuer_location)
-               g_free(issuer_location);
-       if (issuer_organization)
-               g_free(issuer_organization);
-       if (subject_commonname)
-               g_free(subject_commonname);
-       if (subject_location)
-               g_free(subject_location);
-       if (subject_organization)
-               g_free(subject_organization);
-       if (fingerprint)
-               g_free(fingerprint);
-       if (sig_status)
-               g_free(sig_status);
+       g_free(issuer_commonname);
+       g_free(issuer_location);
+       g_free(issuer_organization);
+       g_free(subject_commonname);
+       g_free(subject_location);
+       g_free(subject_organization);
+       g_free(fingerprint);
+       g_free(sig_status);
        return ret;
 }
        
@@ -219,8 +212,7 @@ void ssl_certificate_destroy(SSLCertificate *cert)
 
        if (cert->x509_cert)
                X509_free(cert->x509_cert);
-       if (cert->host) 
-               g_free(cert->host);
+       g_free(cert->host);
        g_free(cert);
        cert = NULL;
 }
@@ -233,7 +225,7 @@ void ssl_certificate_delete_from_disk(SSLCertificate *cert)
        file = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, 
                          "certs", G_DIR_SEPARATOR_S,
                          cert->host, ".", buf, ".cert", NULL);
-       unlink (file);
+       g_unlink (file);
        g_free(buf);
        g_free(file);
 }
@@ -263,7 +255,7 @@ SSLCertificate *ssl_certificate_find_lookup (gchar *host, gushort port, gboolean
                          fqdn_host, ".", buf, ".cert", NULL);
 
        g_free(buf);
-       fp = fopen(file, "rb");
+       fp = g_fopen(file, "rb");
        if (fp == NULL) {
                g_free(file);
                g_free(fqdn_host);
@@ -342,20 +334,6 @@ gboolean ssl_certificate_check (X509 *x509_cert, gchar *host, gushort port)
                
                sig_status = ssl_certificate_check_signer(x509_cert);
 
-#if 0 /* disabled pref for now */
-               if (sig_status == NULL && !prefs_common.ssl_ask_unknown_valid) {
-                       /* trust and accept silently if hostnames match */
-                       char *buf; /* don't free buf ! */
-                       if (X509_NAME_get_text_by_NID(X509_get_subject_name(x509_cert), 
-                                      NID_commonName, buf, 100) >= 0)
-                               if (!strcmp(buf, current_cert->host)) {
-                                       g_free(sig_status);
-                                       ssl_certificate_save(current_cert);
-                                       ssl_certificate_destroy(current_cert);
-                                       return TRUE;            
-                               }
-               }
-#endif
                g_free(sig_status);
 
                cur_cert_str = ssl_certificate_to_string(current_cert);
@@ -365,15 +343,6 @@ gboolean ssl_certificate_check (X509 *x509_cert, gchar *host, gushort port)
                                          cur_cert_str);
                g_free (cur_cert_str);
 
-#if 0 /* disabled for now */
-               if (prefs_common.no_recv_err_panel) {
-                       log_error(_("%s\n\nMail won't be retrieved on this account until you save the certificate.\n(Uncheck the \"%s\" preference).\n"),
-                                       err_msg,
-                                       _("Don't popup error dialog on receive error"));
-                       g_free(err_msg);
-                       return FALSE;
-               }
-#endif
                cert_hook_data.cert = current_cert;
                cert_hook_data.old_cert = NULL;
                cert_hook_data.accept = FALSE;
@@ -403,15 +372,6 @@ gboolean ssl_certificate_check (X509 *x509_cert, gchar *host, gushort port)
                g_free (cur_cert_str);
                g_free (known_cert_str);
 
-#if 0
-               if (prefs_common.no_recv_err_panel) {
-                       log_error(_("%s\n\nMail won't be retrieved on this account until you save the certificate.\n(Uncheck the \"%s\" preference).\n"),
-                                       err_msg,
-                                       _("Don't popup error dialog on receive error"));
-                       g_free(err_msg);
-                       return FALSE;
-               }
-#endif
                cert_hook_data.cert = current_cert;
                cert_hook_data.old_cert = known_cert;
                cert_hook_data.accept = FALSE;