Last change
on this file since 10233 was 9795, checked in by stuerze, 2 years ago |
consideration of client SSL certificates, if they are available
|
File size:
1.8 KB
|
Rev | Line | |
---|
[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 | *
|
---|
[9739] | 13 | * Changes:
|
---|
[3347] | 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 |
|
---|
[9739] | 26 |
|
---|
| 27 | // Singleton
|
---|
| 28 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 29 | bncSslConfig bncSslConfig::instance() {
|
---|
| 30 | static bncSslConfig _sslConfig;
|
---|
| 31 | return _sslConfig;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
[3347] | 34 | // Constructor
|
---|
| 35 | ////////////////////////////////////////////////////////////////////////////
|
---|
[9739] | 36 | bncSslConfig::bncSslConfig() :
|
---|
[9795] | 37 | QSslConfiguration(QSslConfiguration::defaultConfiguration()) {
|
---|
[9739] | 38 |
|
---|
[3358] | 39 | bncSettings settings;
|
---|
| 40 | QString dirName = settings.value("sslCaCertPath").toString();
|
---|
| 41 | if (dirName.isEmpty()) {
|
---|
| 42 | dirName = defaultPath();
|
---|
| 43 | }
|
---|
[3350] | 44 |
|
---|
| 45 | QList<QSslCertificate> caCerts = this->caCertificates();
|
---|
| 46 |
|
---|
| 47 | QDir dir(dirName);
|
---|
[9756] | 48 | QStringList nameFilters;
|
---|
| 49 | nameFilters << "*.crt";
|
---|
| 50 | nameFilters << "*.pem";
|
---|
[3350] | 51 | QStringList fileNames = dir.entryList(nameFilters, QDir::Files);
|
---|
| 52 | QStringListIterator it(fileNames);
|
---|
| 53 | while (it.hasNext()) {
|
---|
| 54 | QString fileName = it.next();
|
---|
| 55 | caCerts += QSslCertificate::fromPath(dirName+QDir::separator()+fileName);
|
---|
| 56 | }
|
---|
[9739] | 57 |
|
---|
[3348] | 58 | this->setCaCertificates(caCerts);
|
---|
[9795] | 59 |
|
---|
| 60 |
|
---|
[3347] | 61 | }
|
---|
| 62 |
|
---|
| 63 | // Destructor
|
---|
| 64 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 65 | bncSslConfig::~bncSslConfig() {
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[3357] | 68 | // Destructor
|
---|
| 69 | ////////////////////////////////////////////////////////////////////////////
|
---|
| 70 | QString bncSslConfig::defaultPath() {
|
---|
[9753] | 71 | return "/etc/ssl/certs/";
|
---|
[3357] | 72 | }
|
---|
| 73 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.