source: ntrip/trunk/BNC/src/bncsslconfig.cpp@ 8282

Last change on this file since 8282 was 8252, checked in by stoecker, 7 years ago

see #105 - reenable Qt4 build options, drop generic version dependend includes, replace by direct requirements, remaining QtCore lines should also be replaced

File size: 1.9 KB
Line 
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 <QApplication>
20#include <QDir>
21#include <QStringList>
22
23#include "bncsslconfig.h"
24#include "bncsettings.h"
25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
28bncSslConfig::bncSslConfig() :
29 QSslConfiguration(QSslConfiguration::defaultConfiguration())
30{
31
32 bncSettings settings;
33 QString dirName = settings.value("sslCaCertPath").toString();
34 if (dirName.isEmpty()) {
35 dirName = defaultPath();
36 }
37
38 QList<QSslCertificate> caCerts = this->caCertificates();
39
40 // Bug in Qt: the wildcard does not work here:
41 // -------------------------------------------
42 // caCerts += QSslCertificate::fromPath(dirName + QDir::separator() + "*crt",
43 // QSsl::Pem, QRegExp::Wildcard);
44 QDir dir(dirName);
45 QStringList nameFilters; nameFilters << "*.crt";
46 QStringList fileNames = dir.entryList(nameFilters, QDir::Files);
47 QStringListIterator it(fileNames);
48 while (it.hasNext()) {
49 QString fileName = it.next();
50 caCerts += QSslCertificate::fromPath(dirName+QDir::separator()+fileName);
51 }
52
53 this->setCaCertificates(caCerts);
54}
55
56// Destructor
57////////////////////////////////////////////////////////////////////////////
58bncSslConfig::~bncSslConfig() {
59}
60
61// Destructor
62////////////////////////////////////////////////////////////////////////////
63QString bncSslConfig::defaultPath() {
64 return QDir::homePath() + QDir::separator()
65 + ".config" + QDir::separator() + qApp->organizationName();
66}
67
Note: See TracBrowser for help on using the repository browser.