about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/connection.c28
-rw-r--r--src/xmpp/xmpp.h3
2 files changed, 25 insertions, 6 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 2986b0bc..dce836bc 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -387,16 +387,34 @@ _connection_free_session_data(void)
 
 #ifdef HAVE_LIBMESODE
 static int
-_connection_certfail_cb(const char *const certname, const char *const certfp,
-    char *const notbefore, const char *const notafter, const char *const errormsg)
+_connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg)
 {
-    return sv_ev_certfail(errormsg, certname, certfp, notbefore, notafter);
+    char *subjectname = xmpp_conn_tlscert_subjectname(xmpptlscert);
+    char *fp = xmpp_conn_tlscert_fp(xmpptlscert);
+    char *notbefore = xmpp_conn_tlscert_notbefore(xmpptlscert);
+    char *notafter = xmpp_conn_tlscert_notafter(xmpptlscert);
+
+    TLSCertificate *cert = tlscerts_new(fp, subjectname, notbefore, notafter);
+    int res = sv_ev_certfail(errormsg, cert);
+    tlscerts_free(cert);
+
+    return res;
 }
 
-char*
+TLSCertificate*
 jabber_get_tls_peer_cert(void)
 {
-    return xmpp_conn_tls_peer_cert(jabber_conn.conn);
+    xmpp_tlscert_t *xmpptlscert = xmpp_conn_tls_peer_cert(jabber_conn.conn);
+    char *subjectname = xmpp_conn_tlscert_subjectname(xmpptlscert);
+    char *fp = xmpp_conn_tlscert_fp(xmpptlscert);
+    char *notbefore = xmpp_conn_tlscert_notbefore(xmpptlscert);
+    char *notafter = xmpp_conn_tlscert_notafter(xmpptlscert);
+
+    TLSCertificate *cert = tlscerts_new(fp, subjectname, notbefore, notafter);
+
+    xmpp_conn_free_tlscert(jabber_conn.ctx, xmpptlscert);
+
+    return cert;
 }
 #endif
 
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 00f83d3f..f52603eb 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -45,6 +45,7 @@
 #endif
 
 #include "config/accounts.h"
+#include "config/tlscerts.h"
 #include "contact.h"
 #include "jid.h"
 #include "tools/autocomplete.h"
@@ -153,7 +154,7 @@ GList* jabber_get_available_resources(void);
 char* jabber_create_uuid(void);
 void jabber_free_uuid(char *uuid);
 #ifdef HAVE_LIBMESODE
-char* jabber_get_tls_peer_cert(void);
+TLSCertificate* jabber_get_tls_peer_cert(void);
 #endif
 gboolean jabber_conn_is_secured(void);