summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/TLS/Certificate.cpp')
-rw-r--r--Swiften/TLS/Certificate.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/Swiften/TLS/Certificate.cpp b/Swiften/TLS/Certificate.cpp
index 7d61b22..984d668 100644
--- a/Swiften/TLS/Certificate.cpp
+++ b/Swiften/TLS/Certificate.cpp
@@ -4,7 +4,12 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/TLS/Certificate.h"
+#include <Swiften/TLS/Certificate.h>
+
+#include <sstream>
+
+#include <Swiften/StringCodecs/SHA1.h>
+#include <Swiften/StringCodecs/Hexify.h>
namespace Swift {
@@ -14,4 +19,16 @@ const char* Certificate::ID_ON_DNSSRV_OID = "1.3.6.1.5.5.7.8.7";
Certificate::~Certificate() {
}
+String Certificate::getSHA1Fingerprint() const {
+ ByteArray hash = SHA1::getHash(toDER());
+ std::ostringstream s;
+ for (size_t i = 0; i < hash.getSize(); ++i) {
+ if (i > 0) {
+ s << ":";
+ }
+ s << Hexify::hexify(hash[i]).getUTF8String();
+ }
+ return String(s.str());
+}
+
}