* please see the file GPL in the top level source directory.
*/
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include <lib-lib/lib-lib.h>
#ifdef USE_SSL
#include <openssl/err.h>
#include <openssl/rand.h>
-#include <string.h>
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/macros.h>
-#include <lib-lib/debug.h>
-
#include <lib-ui/curses.h>
#include <lib-ui/menu.h>
ssldata = p_new(sslsockdata, 1);
/* the ssl_use_xxx protocol options don't apply. We must use TLS in TLS. */
if (!(ssldata->ctx = SSL_CTX_new (TLSv1_client_method ()))) {
- debug_print (1, ("Error allocating SSL_CTX\n"));
goto bail_ssldata;
}
ssl_get_client_cert (ssldata, conn);
if (!(ssldata->ssl = SSL_new (ssldata->ctx))) {
- debug_print (1, ("Error allocating SSL\n"));
goto bail_ctx;
}
if (SSL_set_fd (ssldata->ssl, conn->fd) != 1) {
- debug_print (1, ("Error setting fd\n"));
goto bail_ssl;
}
if (option (OPTSSLSYSTEMCERTS)) {
if (X509_STORE_set_default_paths (ctx))
pass++;
- else
- debug_print (2, ("X509_STORE_set_default_paths failed\n"));
}
if (X509_STORE_load_locations (ctx, SslCertFile, NULL))
pass++;
- else
- debug_print (2, ("X509_STORE_load_locations_failed\n"));
if (pass == 0) {
/* nothing to do */
X509_STORE_CTX_init (&xsc, ctx, peercert, NULL);
pass = (X509_verify_cert (&xsc) > 0);
-#ifdef DEBUG
- if (!pass) {
- char buf[SHORT_STRING];
- int err;
-
- err = X509_STORE_CTX_get_error (&xsc);
- snprintf (buf, sizeof (buf), "%s (%d)",
- X509_verify_cert_error_string (err), err);
- debug_print (2, ("X509_verify_cert: %s\n", buf));
- }
-#endif
X509_STORE_CTX_cleanup (&xsc);
X509_STORE_free (ctx);
/* expiration check */
if (X509_cmp_current_time (X509_get_notBefore (peercert)) >= 0) {
- debug_print (2, ("Server certificate is not yet valid\n"));
mutt_error (_("Server certificate is not yet valid"));
mutt_sleep (2);
return 0;
}
if (X509_cmp_current_time (X509_get_notAfter (peercert)) <= 0) {
- debug_print (2, ("Server certificate has expired\n"));
mutt_error (_("Server certificate has expired"));
mutt_sleep (2);
return 0;
/* check session cache first */
if (check_certificate_cache (data->cert)) {
- debug_print (1, ("ssl_check_certificate: using cached certificate\n"));
return 1;
}
if (check_certificate_by_signer (data->cert)) {
- debug_print (1, ("signer check passed\n"));
return 1;
}
/* automatic check from user's database */
if (SslCertFile && check_certificate_by_digest (data->cert)) {
- debug_print (1, ("digest check passed\n"));
return 1;
}
static void ssl_get_client_cert (sslsockdata * ssldata, CONNECTION * conn)
{
if (SslClientCert) {
- debug_print (2, ("Using client certificate %s\n", SslClientCert));
SSL_CTX_set_default_passwd_cb_userdata (ssldata->ctx, &conn->account);
SSL_CTX_set_default_passwd_cb (ssldata->ctx, ssl_passwd_cb);
SSL_CTX_use_certificate_file (ssldata->ctx, SslClientCert,
if (mutt_account_getuser (account))
return 0;
- debug_print (2, ("getting password for %s@%s:%u\n",
- account->user, account->host, account->port));
-
if (mutt_account_getpass (account))
return 0;