1 | /* -------------------------------------------------------------------------
|
---|
2 | * BKG NTRIP Client
|
---|
3 | * -------------------------------------------------------------------------
|
---|
4 | *
|
---|
5 | * Class: bncSslConfig
|
---|
6 | *
|
---|
7 | * Purpose: Singleton Class that inherits QSslConfiguration class
|
---|
8 | *
|
---|
9 | * Author: L. Mervart
|
---|
10 | *
|
---|
11 | * Created: 22-Aug-2011
|
---|
12 | *
|
---|
13 | * Changes:
|
---|
14 | *
|
---|
15 | * -----------------------------------------------------------------------*/
|
---|
16 |
|
---|
17 | #include <iostream>
|
---|
18 |
|
---|
19 | #include "bncsslconfig.h"
|
---|
20 |
|
---|
21 | // Constructor
|
---|
22 | ////////////////////////////////////////////////////////////////////////////
|
---|
23 | bncSslConfig::bncSslConfig() :
|
---|
24 | QSslConfiguration(QSslConfiguration::defaultConfiguration())
|
---|
25 | {
|
---|
26 |
|
---|
27 | QString dirName = QDir::homePath() + QDir::separator()
|
---|
28 | + ".config" + QDir::separator() + qApp->organizationName();
|
---|
29 |
|
---|
30 | QList<QSslCertificate> caCerts = this->caCertificates();
|
---|
31 |
|
---|
32 | // Bug in Qt: the wildcard does not work here:
|
---|
33 | // -------------------------------------------
|
---|
34 | // caCerts += QSslCertificate::fromPath(dirName + QDir::separator() + "*crt",
|
---|
35 | // QSsl::Pem, QRegExp::Wildcard);
|
---|
36 | QDir dir(dirName);
|
---|
37 | QStringList nameFilters; nameFilters << "*.crt";
|
---|
38 | QStringList fileNames = dir.entryList(nameFilters, QDir::Files);
|
---|
39 | QStringListIterator it(fileNames);
|
---|
40 | while (it.hasNext()) {
|
---|
41 | QString fileName = it.next();
|
---|
42 | caCerts += QSslCertificate::fromPath(dirName+QDir::separator()+fileName);
|
---|
43 | }
|
---|
44 |
|
---|
45 | this->setCaCertificates(caCerts);
|
---|
46 | }
|
---|
47 |
|
---|
48 | // Destructor
|
---|
49 | ////////////////////////////////////////////////////////////////////////////
|
---|
50 | bncSslConfig::~bncSslConfig() {
|
---|
51 | }
|
---|
52 |
|
---|