From 60ec923d1f2e5865231d91fb65934a2bb6703323 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sun, 14 Dec 2014 09:58:00 +0000 Subject: [PATCH] Fix calculation of SSL fingerprints --- src/IRCSock.cpp | 9 ++++++++- src/Socket.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/IRCSock.cpp b/src/IRCSock.cpp index 994ff72c..0de72373 100644 --- a/src/IRCSock.cpp +++ b/src/IRCSock.cpp @@ -1146,7 +1146,14 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) { // It shouldn't contain any bad characters, but let's be safe... m_pNetwork->PutStatus("|" + s.Escape_n(CString::EDEBUG)); } - m_pNetwork->PutStatus("If you trust this certificate, do /znc AddTrustedServerFingerprint " + GetSSLPeerFingerprint()); + CString sSHA1; + if (GetPeerFingerprint(sSHA1)) + m_pNetwork->PutStatus("SHA1: " + sSHA1); + CString sSHA256 = GetSSLPeerFingerprint(); + m_pNetwork->PutStatus("SHA-256: " + sSHA256); + m_pNetwork->PutStatus("If you trust this certificate, do /znc AddTrustedServerFingerprint " + sSHA256); + + m_pNetwork->PutStatus("Notice for early ZNC git/nightly adopters: if you previously added a fingerprint with lots of :ff: in it, please remove it. It was a bug, sorry. (This message will be removed before release)"); } } #endif diff --git a/src/Socket.cpp b/src/Socket.cpp index 4b5f85e3..23b7a062 100644 --- a/src/Socket.cpp +++ b/src/Socket.cpp @@ -125,7 +125,7 @@ CString CZNCSock::GetSSLPeerFingerprint() const { } CString sResult; sResult.reserve(3*256/8); - for (char c : buf) { + for (unsigned char c : buf) { char b[3]; snprintf(b, 3, "%02x", c); sResult += b;