Mercurial > hg
diff mcabber/mcabber/xmpp.c @ 2203:170597f5365b
Use more generic routines to convert fingerprints to/from hexadecimal
This is a first step towards non-MD5 fingerprints; now we need Loudmouth
support...
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 12 Oct 2015 17:19:19 +0200 |
parents | 527ba1c1873e |
children | 412322678d59 |
line wrap: on
line diff
--- a/mcabber/mcabber/xmpp.c Mon Oct 12 11:41:34 2015 +0200 +++ b/mcabber/mcabber/xmpp.c Mon Oct 12 17:19:19 2015 +0200 @@ -44,6 +44,8 @@ #define RECONNECTION_TIMEOUT 60L +#define FINGERPRINT_LENGTH 16 // Currently Loudmouth only supports MD5 + LmConnection* lconnection = NULL; static guint AutoConnection; @@ -714,8 +716,8 @@ "Certificate hostname does not match expected hostname!"); break; case LM_SSL_STATUS_CERT_FINGERPRINT_MISMATCH: { - char fpr[49] = {0}; - fingerprint_to_hex(lm_ssl_get_fingerprint(ssl), fpr); + char fpr[3*FINGERPRINT_LENGTH] = {0}; + fingerprint_to_hex(lm_ssl_get_fingerprint(ssl), fpr, FINGERPRINT_LENGTH); scr_LogPrint(LPRINT_LOGNORM, "Certificate fingerprint does not match expected fingerprint!"); scr_LogPrint(LPRINT_LOGNORM, "Remote fingerprint: %s", fpr); @@ -743,8 +745,8 @@ { LmSSL *lssl; if ((lssl = lm_connection_get_ssl(connection)) != NULL) { - char fpr[49] = {0}; - fingerprint_to_hex(lm_ssl_get_fingerprint(lssl), fpr); + char fpr[3*FINGERPRINT_LENGTH] = {0}; + fingerprint_to_hex(lm_ssl_get_fingerprint(lssl), fpr, FINGERPRINT_LENGTH); scr_LogPrint(LPRINT_LOGNORM, "Connection established.\n" "Remote fingerprint: %s", fpr); } @@ -1738,7 +1740,7 @@ { const char *userjid, *password, *resource, *servername, *ssl_fpr; char *dynresource = NULL; - char fpr[17] = {0}; + char fpr[FINGERPRINT_LENGTH] = {0}; const char *proxy_host; const char *resource_prefix = PACKAGE_NAME; char *fjid; @@ -1883,7 +1885,7 @@ port = (ssl ? LM_CONNECTION_DEFAULT_PORT_SSL : LM_CONNECTION_DEFAULT_PORT); lm_connection_set_port(lconnection, port); - if (ssl_fpr && (!hex_to_fingerprint(ssl_fpr, fpr))) { + if (ssl_fpr && (!hex_to_fingerprint(ssl_fpr, fpr, FINGERPRINT_LENGTH))) { scr_LogPrint(LPRINT_LOGNORM, "** Please set the fingerprint in the format " "97:5C:00:3F:1D:77:45:25:E2:C5:70:EC:83:C8:87:EE"); return -1;