Changeset 9795 in ntrip
- Timestamp:
- Jul 22, 2022, 1:34:16 PM (2 years ago)
- Location:
- trunk/BNC/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bncmain.cpp
r9783 r9795 95 95 "\n" 96 96 "Network Panel keys:\n" 97 " proxyHost {Proxy host, name or IP address [character string]}\n" 98 " proxyPort {Proxy port [integer number]}\n" 99 " sslCaCertPath {Full path to SSL certificates [character string]}\n" 100 " sslIgnoreErrors {Ignore SSL authorization errors [integer number: 0=no,2=yes]}\n" 97 " proxyHost {Proxy host, name or IP address [character string]}\n" 98 " proxyPort {Proxy port [integer number]}\n" 99 " sslCaCertPath {Full path to SSL certificates [character string]}\n" 100 " sslClientCertPath {Full path to client SSL certificates [character string]}\n" 101 " sslIgnoreErrors {Ignore SSL authorization errors [integer number: 0=no,2=yes]}\n" 101 102 "\n" 102 103 "General Panel keys:\n" -
trunk/BNC/src/bncnetqueryv2.cpp
r9742 r9795 36 36 37 37 bncSettings settings; 38 _sslIgnoreErrors = 39 (Qt::CheckState(settings.value("sslIgnoreErrors").toInt()) == Qt::Checked); 40 41 if (_secure && !QSslSocket::supportsSsl()) { 42 BNC_CORE->slotMessage("No SSL support, install OpenSSL run-time libraries", true); 43 stop(); 44 } 38 _sslIgnoreErrors = (Qt::CheckState(settings.value("sslIgnoreErrors").toInt()) == Qt::Checked); 39 40 if (_secure ) { 41 if (!QSslSocket::supportsSsl()) { 42 BNC_CORE->slotMessage("No SSL support, install OpenSSL run-time libraries", true); 43 stop(); 44 } 45 // Generate filenames to consider a potential client certificate 46 _crtFileName = settings.value("sslClientCertPath").toString() + _url.host() + QString(".%1.crt").arg(_url.port()); 47 _keyFileName = settings.value("sslClientCertPath").toString() + _url.host() + QString(".%1.key").arg(_url.port()); 48 } 49 50 45 51 } 46 52 … … 122 128 if (_url.scheme().isEmpty()) { 123 129 if (_secure) { 130 _url.setPort(443); 124 131 _url.setScheme("https"); 125 132 } … … 134 141 // Network Request 135 142 // --------------- 143 bncSslConfig sslConfig = BNC_SSL_CONFIG; 144 145 if (_secure) { 146 QFile clientCrtFile(_crtFileName); 147 QFile privateKeyFile(_keyFileName); 148 if ( clientCrtFile.exists() && privateKeyFile.exists()) { 149 // set local certificate if available 150 clientCrtFile.open(QIODevice::ReadOnly); 151 QSslCertificate clientCrt(&clientCrtFile); 152 sslConfig.setLocalCertificate(clientCrt); 153 // set private key if available 154 privateKeyFile.open(QIODevice::ReadOnly); 155 QSslKey privateKey(&privateKeyFile, QSsl::Rsa); 156 sslConfig.setPrivateKey(privateKey); 157 } 158 } 159 136 160 QNetworkRequest request; 137 request.setSslConfiguration( BNC_SSL_CONFIG);161 request.setSslConfiguration(sslConfig); 138 162 request.setUrl(_url); 139 163 request.setRawHeader("Host" , _url.host().toLatin1()); -
trunk/BNC/src/bncnetqueryv2.h
r8252 r9795 7 7 #include <QNetworkReply> 8 8 #include <QSslError> 9 #include <QSslKey> 9 10 10 11 #include "bncnetquery.h" … … 33 34 QNetworkAccessManager* _manager; 34 35 QNetworkReply* _reply; 36 QString _crtFileName; 37 QString _keyFileName; 35 38 QEventLoop* _eventLoop; 36 39 bool _firstData; -
trunk/BNC/src/bncsettings.cpp
r9760 r9795 76 76 setValue_p("proxyPort", ""); 77 77 setValue_p("sslCaCertPath", ""); 78 setValue_p("sslClientCertPath", ""); 78 79 setValue_p("sslIgnoreErrors", "0"); 79 80 // General -
trunk/BNC/src/bncsslconfig.cpp
r9756 r9795 35 35 //////////////////////////////////////////////////////////////////////////// 36 36 bncSslConfig::bncSslConfig() : 37 QSslConfiguration(QSslConfiguration::defaultConfiguration()) 38 { 37 QSslConfiguration(QSslConfiguration::defaultConfiguration()) { 39 38 40 39 bncSettings settings; … … 46 45 QList<QSslCertificate> caCerts = this->caCertificates(); 47 46 48 // Bug in Qt: the wildcard does not work here:49 // -------------------------------------------50 // caCerts += QSslCertificate::fromPath(dirName + QDir::separator() + "*crt",51 // QSsl::Pem, QRegExp::Wildcard);52 47 QDir dir(dirName); 53 48 QStringList nameFilters; … … 62 57 63 58 this->setCaCertificates(caCerts); 59 60 64 61 } 65 62 -
trunk/BNC/src/bncwindow.cpp
r9783 r9795 195 195 this, SLOT(slotBncTextChanged())); 196 196 197 _sslCaCertPathLineEdit = new QLineEdit(settings.value("sslCaCertPath").toString()); 198 _sslIgnoreErrorsCheckBox = new QCheckBox(); 197 _sslCaCertPathLineEdit = new QLineEdit(settings.value("sslCaCertPath").toString()); 198 _sslClientCertPathLineEdit = new QLineEdit(settings.value("sslClientCertPath").toString()); 199 _sslIgnoreErrorsCheckBox = new QCheckBox(); 199 200 _sslIgnoreErrorsCheckBox->setCheckState(Qt::CheckState( 200 201 settings.value("sslIgnoreErrors").toInt())); … … 762 763 pLayout->addWidget(_sslCaCertPathLineEdit, 3, 1, 1,10); 763 764 pLayout->addWidget(new QLabel("Default: " + bncSslConfig::defaultPath()), 3,11, 1,20); 764 pLayout->addWidget(new QLabel("Ignore SSL authorization errors"), 4, 0); 765 pLayout->addWidget(_sslIgnoreErrorsCheckBox, 4, 1, 1,10); 766 pLayout->addWidget(new QLabel(""), 5, 1); 765 pLayout->addWidget(new QLabel("Path to SSL client certificates"), 4, 0); 766 pLayout->addWidget(_sslClientCertPathLineEdit, 4, 1, 1,10); 767 pLayout->addWidget(new QLabel("Ignore SSL authorization errors"), 5, 0); 768 pLayout->addWidget(_sslIgnoreErrorsCheckBox, 5, 1, 1,10); 769 pLayout->addWidget(new QLabel(""), 6, 1); 767 770 pLayout->setRowStretch(6, 999); 768 771 … … 1370 1373 _proxyHostLineEdit->setWhatsThis(tr("<p>If you are running BNC within a protected Local Area Network (LAN), you may need to use a proxy server to access the Internet. Enter your proxy server IP and port number in case one is operated in front of BNC. If you do not know the IP and port of your proxy server, check the proxy server settings in your Internet browser or ask your network administrator. Without any entry, BNC will try to use the system proxies. </p><p>Note that IP streaming is sometimes not allowed in a LAN. In this case you need to ask your network administrator for an appropriate modification of the local security policy or for the installation of a TCP relay to the Ntrip Broadcasters. If this is not possible, you may need to run BNC outside your LAN on a network that has unobstructed connection to the Internet. <i>[key: proxyHost]</i></p>")); 1371 1374 _proxyPortLineEdit->setWhatsThis(tr("<p>Enter your proxy server port number in case a proxy is operated in front of BNC. <i>[key: proxyPort]</i></p>")); 1372 _sslCaCertPathLineEdit->setWhatsThis(tr("<p>Communication with an Ntrip Broadcaster over SSL requires the exchange of client and/or server certificates. Specify the path to a directory where you save certificates on your system. Don't try communication via SSL if you are not sure whether this is supported by the involved Ntrip Broadcaster.</p><p>Note that SSL communication is usually done over port 443. <i>[key: sslCaCertPath]</i></p>")); 1375 _sslCaCertPathLineEdit->setWhatsThis(tr("<p>Communication with an Ntrip Broadcaster over SSL requires the exchange of server certificates. Specify the path to a directory where you save CA certificates on your system. </p><p>BNC creates from *.crt and *.pem files a CA certificate database, which is used by the socket during the handshake phase to validate the peer's certificate. </p><p>Don't try communication via SSL if you are not sure whether this is supported by the involved Ntrip Broadcaster.</p><p>Note that SSL communication is usually done over port 443. <i>[key: sslCaCertPath]</i></p>")); 1376 _sslClientCertPathLineEdit->setWhatsThis(tr("<p>Two-sided communication with an Ntrip Broadcaster over SSL requires in addition the exchange of client certificates. Specify the full path to the client certificates on your system.</p><p></p><p>The file naming convention for client certificates in BNC is as follows: <hostname>.<port>.crt for the certificate and <hostname>.<port>.key for the private key, where <hostname> is without https://. </p><p> If available, the client or personal authentication certificate is presented to the peer during the SSL handshake process. Password protected key files are not supported. </p><p>Don't try communication via two sided SSL if you are not sure whether this is supported by the involved Ntrip Broadcaster. </p><p>Note that SSL communication is usually done over port 443. <i>[key: sslClientCertPath]</i></p>")); 1373 1377 _sslIgnoreErrorsCheckBox->setWhatsThis(tr("<p>SSL communication may involve queries coming from the Ntrip Broadcaster. Tick 'Ignore SSL authorization errors' if you don't want to be bothered with this. <i>[key: sslIgnoreErrors]</i></p>")); 1374 1378 … … 1593 1597 delete _proxyPortLineEdit; 1594 1598 delete _sslCaCertPathLineEdit; 1599 delete _sslClientCertPathLineEdit; 1595 1600 delete _sslIgnoreErrorsCheckBox; 1596 1601 delete _logFileLineEdit; … … 1780 1785 1781 1786 settings.setValue("sslCaCertPath", _sslCaCertPathLineEdit->text()); 1787 settings.setValue("sslClientCertPath", _sslClientCertPathLineEdit->text()); 1782 1788 settings.setValue("sslIgnoreErrors", _sslIgnoreErrorsCheckBox->checkState()); 1783 1789 … … 2055 2061 settings.setValue("proxyPort", _proxyPortLineEdit->text()); 2056 2062 settings.setValue("sslCaCertPath", _sslCaCertPathLineEdit->text()); 2057 settings.setValue("sslIgnoreErrors", _sslIgnoreErrorsCheckBox->checkState()); 2063 settings.setValue("sslClientCertPath", _sslClientCertPathLineEdit->text()); 2064 settings.setValue("sslIgnoreErrors", _sslIgnoreErrorsCheckBox->checkState()); 2058 2065 // General 2059 2066 settings.setValue("logFile", _logFileLineEdit->text()); -
trunk/BNC/src/bncwindow.h
r9760 r9795 134 134 QLineEdit* _proxyPortLineEdit; 135 135 QLineEdit* _sslCaCertPathLineEdit; 136 QLineEdit* _sslClientCertPathLineEdit; 136 137 QCheckBox* _sslIgnoreErrorsCheckBox; 137 138 QLineEdit* _outFileLineEdit; -
trunk/BNC/src/upload/bncuploadcaster.cpp
r9757 r9795 79 79 _secure = true; 80 80 _casterOutPort = 443; 81 // Generate filenames to consider a potential client certificate and private key 82 _crtFileName = settings.value("sslClientCertPath").toString() + _casterOutHost + QString(".%1.crt").arg(_casterOutPort); 83 _keyFileName = settings.value("sslClientCertPath").toString() + _casterOutHost + QString(".%1.key").arg(_casterOutPort); 81 84 } 82 85 } … … 215 218 _outSocket->ignoreSslErrors(); 216 219 } else { 217 _outSocket->setSslConfiguration(BNC_SSL_CONFIG); 220 bncSslConfig sslConfig = BNC_SSL_CONFIG; 221 QFile clientCrtFile(_crtFileName); 222 QFile privateKeyFile(_keyFileName); 223 if ( clientCrtFile.exists() && privateKeyFile.exists()) { 224 // set local certificate 225 clientCrtFile.open(QIODevice::ReadOnly); 226 QSslCertificate clientCrt(&clientCrtFile); 227 sslConfig.setLocalCertificate(clientCrt); 228 // set private key if available 229 privateKeyFile.open(QIODevice::ReadOnly); 230 QSslKey privateKey(&privateKeyFile, QSsl::Rsa); 231 sslConfig.setPrivateKey(privateKey); 232 } 233 _outSocket->setSslConfiguration(sslConfig); 218 234 connect(_outSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); 219 235 } -
trunk/BNC/src/upload/bncuploadcaster.h
r9748 r9795 8 8 #include <QThread> 9 9 #include <QSslError> 10 #include <QSslKey> 10 11 #include <iostream> 11 12 … … 50 51 QString _proxyOutHost; 51 52 int _proxyOutPort; 53 QString _crtFileName; 54 QString _keyFileName; 52 55 QString _userName; 53 56 QString _password;
Note:
See TracChangeset
for help on using the changeset viewer.