changeset: 6617:0b66f6fd3d44
user: Kevin McCarthy <[email protected]>
date: Mon Apr 11 11:55:50 2016 -0700
link: http://dev.mutt.org/hg/mutt/rev/0b66f6fd3d44
Add an error message and debugging if SSL_CTX_new() fails. (closes #3831)
Generate a mutt_error(). Add a debugging function
ssl_dprint_err_stack() to dprint the ssl error stack.
diffs (47 lines):
diff -r 78aa3a1db632 -r 0b66f6fd3d44 mutt_ssl.c
--- a/mutt_ssl.c Mon Apr 11 11:28:22 2016 +0200
+++ b/mutt_ssl.c Mon Apr 11 11:55:50 2016 -0700
@@ -82,6 +82,7 @@
static int ssl_socket_close (CONNECTION * conn);
static int tls_close (CONNECTION* conn);
static void ssl_err (sslsockdata *data, int err);
+static void ssl_dprint_err_stack (void);
static int ssl_cache_trusted_cert (X509 *cert);
static int ssl_check_certificate (CONNECTION *conn, sslsockdata * data);
static int interactive_check_cert (X509 *cert, int idx, int len);
@@ -336,6 +337,12 @@
if (! (data->ctx = SSL_CTX_new (SSLv23_client_method ())))
{
+ /* L10N: an SSL context is a data structure returned by the OpenSSL
+ * function SSL_CTX_new(). In this case it returned NULL: an
+ * error condition.
+ */
+ mutt_error (_("Unable to create SSL context"));
+ ssl_dprint_err_stack ();
mutt_socket_close (conn);
return -1;
}
@@ -537,6 +544,22 @@
dprint (1, (debugfile, "SSL error: %s\n", errmsg));
}
+static void ssl_dprint_err_stack (void)
+{
+#ifdef DEBUG
+ BIO *bio;
+ char *buf = NULL;
+
+ if (! (bio = BIO_new (BIO_s_mem ())))
+ return;
+ ERR_print_errors (bio);
+ if (BIO_get_mem_data (bio, &buf))
+ dprint (1, (debugfile, "SSL error stack: %s\n", buf));
+ BIO_free (bio);
+#endif
+}
+
+
static char *x509_get_part (char *line, const char *ndx)
{
static char ret[SHORT_STRING];