Mercurial > trustbridge
comparison ui/createcertlistdialog.cpp @ 679:75cd2fbf9ac6
(Issue 9) Log key's sha256 fingerprint
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 30 Jun 2014 17:21:44 +0200 |
parents | ccdc4c6b97ce |
children | bd2cb6bdb1c5 |
comparison
equal
deleted
inserted
replaced
678:237af0c82454 | 679:75cd2fbf9ac6 |
---|---|
270 if (!outputFile.copy(curCerts)) { | 270 if (!outputFile.copy(curCerts)) { |
271 showErrorMessage(tr("Failed to write current_certificates file.")); | 271 showErrorMessage(tr("Failed to write current_certificates file.")); |
272 return; | 272 return; |
273 } | 273 } |
274 | 274 |
275 | |
276 QString keyFingerprint; | |
277 | |
278 { | |
279 /* Calculate sha256 sum of the der key */ | |
280 unsigned char output_buf[16000]; /* Buf size taken from examples */ | |
281 int ret; | |
282 ret = pk_write_key_der (mPk, output_buf, 16000); | |
283 if (ret <= 0) { | |
284 showErrorMessage(tr("Failed to calculate key hash.")); | |
285 return; | |
286 } | |
287 QByteArray derKey((const char*)output_buf, ret); | |
288 QByteArray fp = sha256sum(derKey); | |
289 | |
290 for (int i=0; i < fp.size(); i++) { | |
291 keyFingerprint += QString("%1").arg( | |
292 (unsigned char)(fp[i]), 0, 16).rightJustified(2, '0'); | |
293 if (i != fp.size() - 1) { | |
294 keyFingerprint += ":"; | |
295 } | |
296 } | |
297 keyFingerprint = keyFingerprint.toUpper(); | |
298 } | |
299 | |
300 mAdminWindow->logChanges(curCerts, keyFingerprint); | |
301 | |
275 QMessageBox::information(this, "", tr("Saved certificate list:\n%1").arg(fileName)); | 302 QMessageBox::information(this, "", tr("Saved certificate list:\n%1").arg(fileName)); |
276 mAdminWindow->logChanges(curCerts); | |
277 close(); | 303 close(); |
278 } | 304 } |