various fixes and simplifications wrt openssl.h
[apps/madmutt.git] / sendlib.c
index 8891280..0f33616 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
 #include <signal.h>
 
 #ifdef USE_LIBESMTP
+#ifdef HAVE_GNUTLS_OPENSSL_H
+#define SSL_SESSION_ASN1_VERSION
+#include <gnutls/openssl.h>
+#endif
 #include <auth-client.h>
 #include <libesmtp.h>
 #endif
@@ -186,17 +190,6 @@ _send_smtp_messagefp_cb(void **buf, int *len, void *arg)
   return *buf;
 }
 
-static int handle_invalid_peer_certificate (long vfy_result) {
-#if defined (HAVE_GNUTLS_OPENSSL_H)
-  mutt_error (_("Error verifying certificate: %s"),
-              NONULL (X509_verify_cert_error_string (vfy_result)));
-#else
-  mutt_error (_("Error verifying certificate. Error Code: %lu"), vfy_result);
-#endif
-  sleep(2);
-  return 1; /* Accept the problem */
-}
-
 static void event_cb (smtp_session_t session __attribute__ ((unused)),
                       int event_no, void *arg,...)
 { 
@@ -225,8 +218,9 @@ static void event_cb (smtp_session_t session __attribute__ ((unused)),
   case SMTP_EV_INVALID_PEER_CERTIFICATE: {
     long vfy_result;
     vfy_result = va_arg(alist, long); ok = va_arg(alist, int*);
-    *ok = handle_invalid_peer_certificate(vfy_result);
-    sleep(1);
+    mutt_error (_("Error verifying certificate. Error Code: %lu"), vfy_result);
+    sleep(2);
+    *ok = 1;
     break;
   } 
   case SMTP_EV_NO_PEER_CERTIFICATE: {
@@ -317,8 +311,8 @@ int send_smtp_check_usetls (const char* option, unsigned long p,
 static int
 send_smtp_invoke(address_t *from, address_t *to, address_t *cc,
                  address_t *bcc, const char *msg, int eightbit)
-{                               /* message contains 8bit chars */
-  int ret = 0;                  /* return value, default = success */
+{
+  int ret = 0;
   smtp_session_t session;
   smtp_message_t message;
   char *hostportstr = NULL;
@@ -334,9 +328,9 @@ send_smtp_invoke(address_t *from, address_t *to, address_t *cc,
     SMTPFAIL ("smtp_create_session");
 
 #ifdef HAVE_GNUTLS_OPENSSL_H
-  if (SmtpUseTLS != NULL && ascii_strncasecmp("enabled", SmtpUseTLS, 7) == 0) {
+  if (!ascii_strncasecmp("enabled", SmtpUseTLS, 7)) {
     smtp_starttls_enable(session, Starttls_ENABLED);
-  } else if (SmtpUseTLS != NULL && ascii_strncasecmp("required", SmtpUseTLS, 8) == 0) {
+  } else if (!ascii_strncasecmp("required", SmtpUseTLS, 8)) {
     smtp_starttls_enable(session, Starttls_REQUIRED);
   }
 #endif