Mercurial > trustbridge
comparison ui/certificate.cpp @ 378:31079bd54036
Add fingerprint to certificate
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 15 Apr 2014 12:36:22 +0200 |
parents | 67b471c4d1fc |
children | 2ddc685cba33 |
comparison
equal
deleted
inserted
replaced
377:e3f825a7257e | 378:31079bd54036 |
---|---|
1 #include "certificate.h" | 1 #include "certificate.h" |
2 #include <QDebug> | 2 #include <QDebug> |
3 #include <QFile> | 3 #include <QFile> |
4 #include <QStringList> | 4 #include <QStringList> |
5 #include <QObject> | 5 #include <QObject> |
6 | |
7 #include <polarssl/sha1.h> | |
6 | 8 |
7 #include "certhelp.h" | 9 #include "certhelp.h" |
8 #include "listutil.h" | 10 #include "listutil.h" |
9 | 11 |
10 /* Qt wrapper around certhelp functions. */ | 12 /* Qt wrapper around certhelp functions. */ |
45 | 47 |
46 mSubjectCN = getX509Value(&(chain.subject), CERT_OID_CN); | 48 mSubjectCN = getX509Value(&(chain.subject), CERT_OID_CN); |
47 mSubjectOU = getX509Value(&(chain.subject), CERT_OID_OU); | 49 mSubjectOU = getX509Value(&(chain.subject), CERT_OID_OU); |
48 mSubjectO = getX509Value(&(chain.subject), CERT_OID_O); | 50 mSubjectO = getX509Value(&(chain.subject), CERT_OID_O); |
49 mSubjectSN = getX509Value(&(chain.subject), CERT_OID_SN); | 51 mSubjectSN = getX509Value(&(chain.subject), CERT_OID_SN); |
52 | |
53 /* Calculate sha1 fingerprint */ | |
54 unsigned char sha1sum[20]; | |
55 sha1(chain.raw.p, chain.raw.len, sha1sum); | |
56 for (int i=0; i < 20; i++) { | |
57 mFingerprint += QString("%1").arg(sha1sum[i], 0, 16); | |
58 if (i != 19) { | |
59 mFingerprint += ":"; | |
60 } | |
61 } | |
62 | |
50 x509_crt_free(&chain); | 63 x509_crt_free(&chain); |
51 | 64 |
52 mDetails = QObject::tr("Certificate:\n" | 65 mDetails = QObject::tr("Certificate:\n" |
53 " <bold>%1</bold>\n" | 66 " <bold>%1</bold>\n" |
54 " %2, %3\n\n" | 67 " %2, %3\n\n" |
60 .arg(mSubjectO) | 73 .arg(mSubjectO) |
61 .arg(mSubjectOU) | 74 .arg(mSubjectOU) |
62 .arg(mSubjectSN) | 75 .arg(mSubjectSN) |
63 .arg(QLocale::system().toString(mValidFrom)) | 76 .arg(QLocale::system().toString(mValidFrom)) |
64 .arg(QLocale::system().toString(mValidTo)); | 77 .arg(QLocale::system().toString(mValidTo)); |
78 | |
65 } | 79 } |
66 | 80 |
67 Certificate::Certificate(const QByteArray& derData) : | 81 Certificate::Certificate(const QByteArray& derData) : |
68 mValid(false) | 82 mValid(false) |
69 { | 83 { |