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

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