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

Last change on this file since 8435 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
RevLine 
[3347]1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncSslConfig
6 *
[3348]7 * Purpose: Singleton Class that inherits QSslConfiguration class
[3347]8 *
9 * Author: L. Mervart
10 *
11 * Created: 22-Aug-2011
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include <iostream>
18
[8252]19#include <QApplication>
20#include <QDir>
21#include <QStringList>
22
[3347]23#include "bncsslconfig.h"
[3358]24#include "bncsettings.h"
[3347]25
26// Constructor
27////////////////////////////////////////////////////////////////////////////
[3350]28bncSslConfig::bncSslConfig() :
29 QSslConfiguration(QSslConfiguration::defaultConfiguration())
30{
[3358]31
32 bncSettings settings;
33 QString dirName = settings.value("sslCaCertPath").toString();
34 if (dirName.isEmpty()) {
35 dirName = defaultPath();
36 }
[3350]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
[3348]53 this->setCaCertificates(caCerts);
[3347]54}
55
56// Destructor
57////////////////////////////////////////////////////////////////////////////
58bncSslConfig::~bncSslConfig() {
59}
60
[3357]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.