comparison ui/certificate.cpp @ 83:ba8a548ff252

Expand certificate class to make raw data accessible
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 20 Mar 2014 16:20:44 +0000
parents 1f27d6db5ee3
children f1ebab8639dc
comparison
equal deleted inserted replaced
82:1f27d6db5ee3 83:ba8a548ff252
1 #include "certificate.h" 1 #include "certificate.h"
2 #include <QDebug> 2 #include <QDebug>
3 #include <QObject> 3 #include <QObject>
4 4
5 const QString& Certificate::shortDescription() const { 5 Certificate::Certificate(const QString& b64Line) :
6 return mShortDescription;
7 }
8
9 Certificate::Certificate(const QByteArray& asn1data) :
10 mValid(false), 6 mValid(false),
11 mShortDescription(QObject::tr("Invalid Certificate")) 7 mShortDescription(QObject::tr("Invalid Certificate"))
12 { 8 {
13 int ret = -1; 9 int ret = -1;
14 char buf[2000]; 10 char buf[2000];
11
12 /* Cut of the first two chars (e.g. I: and decode) */
13 QByteArray asn1data = QByteArray::fromBase64(
14 b64Line.right(b64Line.size() - 2).toLatin1());
15 15
16 x509_crt_init(&mX509Cert); 16 x509_crt_init(&mX509Cert);
17 ret = x509_crt_parse(&mX509Cert, 17 ret = x509_crt_parse(&mX509Cert,
18 (const unsigned char*) asn1data.constData(), 18 (const unsigned char*) asn1data.constData(),
19 asn1data.size()); 19 asn1data.size());
29 return; 29 return;
30 } 30 }
31 31
32 /* In case of success the return value is the size of the information 32 /* In case of success the return value is the size of the information
33 * written into buf 33 * written into buf
34 *
35 * TODO: This is currently not short description but all x509 information
36 * */ 34 * */
37 mShortDescription = QString::fromUtf8(buf, ret); 35
36 mDetails = QString::fromUtf8(buf, ret);
37
38 mShortDescription = mDetails; /* TODO */
38 39
39 mValid = true; 40 mValid = true;
41
42 mBaseLine = b64Line;
40 } 43 }
41 44
42 Certificate::~Certificate() 45 Certificate::~Certificate()
43 { 46 {
44 x509_crt_free(&mX509Cert); 47 x509_crt_free(&mX509Cert);

http://wald.intevation.org/projects/trustbridge/