summaryrefslogtreecommitdiff
path: root/res/res_xmpp.c
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2017-03-24 09:12:57 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-03-24 09:12:57 -0500
commitd3ca0e0bc49feee43a4940e983e6bbd08ae68b29 (patch)
treed79234801f9e1403d43f155acb0cc5868daf68cc /res/res_xmpp.c
parent59df60efb9f05e7339aa19ed2ec62b52ccc1271f (diff)
parentbe94105d6dc0cfb41ed88badd2d7cfd18ab7fe89 (diff)
Merge "res_xmpp: Try to provide useful errors messages from OpenSSL"
Diffstat (limited to 'res/res_xmpp.c')
-rw-r--r--res/res_xmpp.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/res/res_xmpp.c b/res/res_xmpp.c
index 1aa865cd6..4e6685291 100644
--- a/res/res_xmpp.c
+++ b/res/res_xmpp.c
@@ -2629,12 +2629,31 @@ static int xmpp_client_request_tls(struct ast_xmpp_client *client, struct ast_xm
#endif
}
+#ifdef HAVE_OPENSSL
+static char *openssl_error_string(void)
+{
+ char *buf = NULL, *ret;
+ size_t len;
+ BIO *bio = BIO_new(BIO_s_mem());
+
+ ERR_print_errors(bio);
+ len = BIO_get_mem_data(bio, &buf);
+ ret = ast_calloc(1, len + 1);
+ if (ret) {
+ memcpy(ret, buf, len);
+ }
+ BIO_free(bio);
+ return ret;
+}
+#endif
+
/*! \brief Internal function called when we receive a response to our TLS initiation request */
static int xmpp_client_requested_tls(struct ast_xmpp_client *client, struct ast_xmpp_client_config *cfg, int type, iks *node)
{
#ifdef HAVE_OPENSSL
int sock;
long ssl_opts;
+ char *err;
#endif
if (!strcmp(iks_name(node), "success")) {
@@ -2690,7 +2709,10 @@ static int xmpp_client_requested_tls(struct ast_xmpp_client *client, struct ast_
return 0;
failure:
- ast_log(LOG_ERROR, "TLS connection for client '%s' cannot be established. OpenSSL initialization failed.\n", client->name);
+ err = openssl_error_string();
+ ast_log(LOG_ERROR, "TLS connection for client '%s' cannot be established. "
+ "OpenSSL initialization failed: %s\n", client->name, err);
+ ast_free(err);
return -1;
#endif
}