source: ntrip/trunk/BNC/bncsslconfig.cpp@ 3802

Last change on this file since 3802 was 3358, checked in by mervart, 13 years ago
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
19#include "bncsslconfig.h"
[3358]20#include "bncsettings.h"
[3347]21
22// Constructor
23////////////////////////////////////////////////////////////////////////////
[3350]24bncSslConfig::bncSslConfig() :
25 QSslConfiguration(QSslConfiguration::defaultConfiguration())
26{
[3358]27
28 bncSettings settings;
29 QString dirName = settings.value("sslCaCertPath").toString();
30 if (dirName.isEmpty()) {
31 dirName = defaultPath();
32 }
[3350]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
[3348]49 this->setCaCertificates(caCerts);
[3347]50}
51
52// Destructor
53////////////////////////////////////////////////////////////////////////////
54bncSslConfig::~bncSslConfig() {
55}
56
[3357]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.