Changeset 11153 in ntrip for trunk/BNC/src


Ignore:
Timestamp:
Oct 31, 2026, 11:50:15 PM (6 days ago)
Author:
stuerze
Message:

Credentials files are implemented, with existing configs keep working unchanged

Location:
trunk/BNC/src
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncgetthread.cpp

    r11066 r11153  
    6565#include "bncnetqueryudp.h"
    6666#include "bncnetqueryudp0.h"
     67#include "bnccredentials.h"
    6768#include "bncnetquerys.h"
    6869#include "bncsettings.h"
    … …  
    9596  _rawFile = 0;
    9697  _mountPoint   = mountPoint;
     98  _requestUrl   = mountPoint;
     99  bncCredentials::complete(_requestUrl); // password from a credentials file
    97100  _staID        = mountPoint.path().mid(1).toLatin1();
    98101  _format       = format;
    … …  
    356359  msleep(100); //sleep 0.1 sec
    357360
    358   _decoder->initRinex(_staID, _mountPoint, _latitude, _longitude, _nmea,
     361  _decoder->initRinex(_staID, _requestUrl, _latitude, _longitude, _nmea,
    359362      _ntripVersion);
    360363
    … …  
    768771    if (_nmea == "yes") {
    769772      if (_serialNMEA == MANUAL_NMEA) {
    770         _query->startRequest(_mountPoint, _manualNMEAString);
     773        _query->startRequest(_requestUrl, _manualNMEAString);
    771774        _lastNMEA = QDateTime::currentDateTime();
    772775      } else if (_serialNMEA == AUTO_NMEA) {
    … …  
    783786              if (i2 != -1 && data.size() > i2 + 1) {
    784787                QByteArray gga = data.mid(i1, i2 - i1 + 3);
    785                 _query->startRequest(_mountPoint, gga);
     788                _query->startRequest(_requestUrl, gga);
    786789                _lastNMEA = QDateTime::currentDateTime();
    787790              }
    … …  
    791794      }
    792795    } else {
    793       _query->startRequest(_mountPoint, "");
     796      _query->startRequest(_requestUrl, "");
    794797    }
    795798
  • trunk/BNC/src/bncgetthread.h

    r11021 r11153  
    109109   GPSDecoder*                _decoder;
    110110   bncNetQuery*               _query;
    111    QUrl                       _mountPoint;
     111   QUrl                       _mountPoint;   // as configured (identifies the stream)
     112   QUrl                       _requestUrl;   // with password from a credentials file
    112113   QByteArray                 _staID;
    113114   QByteArray                 _format;
  • trunk/BNC/src/bnchelp.html

    r11148 r11153  
    26922692    and feed in manipulated data. The ignored errors are logged. Better save the CA certificate of the Ntrip
    26932693    Broadcaster in the 'Path to SSL certificates' directory.
     2694  </p>
     2695  <p>
     2696    Passwords of Ntrip Broadcasters can be kept in 'Credentials files' instead of BNC's configuration file, which
     2697    then contains no secrets and can be passed on. Give the user name without password in the stream's URL, e.g.
     2698    '//user@products.igs-ip.net:443/SSRA00BKG1', or in the upload settings (empty password). BNC takes the password
     2699    from the first matching entry of the credentials files. Streams without user name are retrieved without
     2700    authentication, even if a file contains an entry for that host. A password still given in the configuration
     2701    file is used as before (with a hint in the logfile), so configurations can be changed step by step.
     2702  </p>
     2703  <p>
     2704    Two file formats are accepted and detected from the content:
     2705  <ul>
     2706    <li>netrc, as used by curl, wget or git: 'machine products.igs-ip.net login user password secret'. The machine
     2707      may also be given as 'host:port' for an account that applies to one port only. The netrc 'default' entry is
     2708      not used.</li>
     2709    <li>BNC: one entry per line '&lt;host&gt; &lt;port&gt; &lt;user&gt; &lt;password&gt;', port '*' for any port,
     2710      user '-' for an entry without user (Ntrip Version 1 upload).</li>
     2711  </ul>
     2712    Several users per host are distinguished by the user name. An entry for the exact port is preferred over one
     2713    for any port. Words containing blanks are quoted: "my secret". A '#' starts a comment. Several files can be
     2714    given, separated by commas; default is the file named in the environment variable NETRC, otherwise ~/.netrc.
     2715    A file readable for other users is not used (chmod 600). Note that a password containing '%' followed by two
     2716    hexadecimal digits is not supported, in the configuration file neither.
    26942717  </p>
    26952718  <p><img src="IMG/Figure07.png" width=800 /></p>
  • trunk/BNC/src/bncmain.cpp

    r11140 r11153  
    136136        "   sslClientCertPath {Full path to client SSL certificates [character string]}\n"
    137137        "   sslIgnoreErrors   {Ignore SSL authorization errors [integer number: 0=no,2=yes]}\n"
     138        "   credentialsFile   {Credentials files, netrc or BNC format, default $NETRC or ~/.netrc [character string, comma separated list]}\n"
    138139        "\n"
    139140        "General Panel keys:\n"
  • trunk/BNC/src/bncsettings.cpp

    r11140 r11153  
    7575        setValue_p("sslClientCertPath", "");
    7676        setValue_p("sslIgnoreErrors", "0");
     77        setValue_p("credentialsFile", "");
    7778        // General
    7879        setValue_p("logFile", "");
  • trunk/BNC/src/bnctabledlg.cpp

    r11116 r11153  
    4747
    4848#include "bnctabledlg.h"
     49#include "bnccredentials.h"
    4950#include "bncgetthread.h"
    5051#include "bncnetqueryv1.h"
    … …  
    238239  }
    239240  url.setUserName(QUrl::toPercentEncoding(casterUser));
    240   url.setPassword(QUrl::toPercentEncoding(casterPassword));
     241  QString password = casterPassword; // empty: from a credentials file
     242  bncCredentials::complete(casterHost, casterPort, casterUser, password, false, false);
     243  url.setPassword(QUrl::toPercentEncoding(password));
    241244  QByteArray outData;
    242245  query->waitForRequestResult(url, outData);
  • trunk/BNC/src/bncwindow.cpp

    r11140 r11153  
    194194  _sslIgnoreErrorsCheckBox->setCheckState(Qt::CheckState(
    195195                                                         settings.value("sslIgnoreErrors").toInt()));
     196  _credentialsFileLineEdit = new QLineEdit(settings.value("credentialsFile").toString());
    196197
    197198  // General Options
    … …  
    828829  pLayout->addWidget(new QLabel("Ignore SSL authorization errors"), 5, 0);
    829830  pLayout->addWidget(_sslIgnoreErrorsCheckBox, 5, 1, 1, 10);
    830   pLayout->addWidget(new QLabel(""), 6, 1);
    831   pLayout->setRowStretch(6, 999);
     831  pLayout->addWidget(new QLabel("Credentials files"), 6, 0);
     832  pLayout->addWidget(_credentialsFileLineEdit, 6, 1, 1, 10);
     833  pLayout->addWidget(new QLabel("Default:  $NETRC or ~/.netrc"), 6, 11, 1, 20);
     834  pLayout->addWidget(new QLabel(""), 7, 1);
     835  pLayout->setRowStretch(7, 999);
    832836
    833837  pgroup->setLayout(pLayout);
    … …  
    15581562  _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>Note that SSL communication is usually done over port 443. <i>[key: sslCaCertPath]</i></p>"));
    15591563  _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: &lt;hostname&gt;.&lt;port&gt;.crt for the certificate and &lt;hostname&gt;.&lt;port&gt;.key for the private key, where &lt;hostname&gt; 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>"));
     1564  _credentialsFileLineEdit->setWhatsThis(tr("<p>Passwords of Ntrip Broadcasters can be kept in credentials files instead of the configuration file: give the user name without password in the stream's URL (e.g. '//user@products.igs-ip.net:443/SSRA00BKG1') or in the upload settings (empty password). BNC then takes the password from the first matching entry of these files. Streams without user name are retrieved without authentication.</p><p>Two formats are accepted, detected from the file content:<br>netrc: 'machine products.igs-ip.net login user password secret', where the machine may also be given as 'host:port';<br>BNC: one entry per line '&lt;host&gt; &lt;port&gt; &lt;user&gt; &lt;password&gt;', port '*' for any port, user '-' for an entry without user (Ntrip Version 1 upload).</p><p>An entry for the exact port is preferred. Several files can be given, separated by commas; default is the file named in the environment variable NETRC or ~/.netrc. A file readable for other users is not used. A password still given in the configuration file is used as before. <i>[key: credentialsFile]</i></p>"));
    15601565  _sslIgnoreErrorsCheckBox->setWhatsThis(tr("<p>Tick 'Ignore SSL authorization errors' to accept a server certificate that cannot be verified, e.g. a self-signed certificate or one issued for another host name. The connection is then still encrypted, but the server is not authenticated: anybody able to intercept the connection may receive your user name and password and feed in manipulated data. The ignored errors are logged. Better save the CA certificate of the Ntrip Broadcaster in the 'Path to SSL certificates' directory. <i>[key: sslIgnoreErrors]</i></p>"));
    15611566
    … …  
    18741879  delete _sslClientCertPathLineEdit;
    18751880  delete _sslIgnoreErrorsCheckBox;
     1881  delete _credentialsFileLineEdit;
    18761882  delete _logFileLineEdit;
    18771883  delete _rawOutFileLineEdit;
    … …  
    20882094  settings.setValue("sslClientCertPath", _sslClientCertPathLineEdit->text());
    20892095  settings.setValue("sslIgnoreErrors", _sslIgnoreErrorsCheckBox->checkState());
     2096  settings.setValue("credentialsFile", _credentialsFileLineEdit->text());
    20902097
    20912098  QMessageBox msgBox;
    … …  
    24042411  settings.setValue("sslClientCertPath", _sslClientCertPathLineEdit->text());
    24052412  settings.setValue("sslIgnoreErrors", _sslIgnoreErrorsCheckBox->checkState());
     2413  settings.setValue("credentialsFile", _credentialsFileLineEdit->text());
    24062414  // General
    24072415  settings.setValue("logFile", _logFileLineEdit->text());
  • trunk/BNC/src/bncwindow.h

    r11140 r11153  
    141141    QLineEdit* _sslClientCertPathLineEdit;
    142142    QCheckBox* _sslIgnoreErrorsCheckBox;
     143    QLineEdit* _credentialsFileLineEdit;
    143144    QLineEdit* _outFileLineEdit;
    144145    QLineEdit* _outPortLineEdit;
  • trunk/BNC/src/src.pri

    r11130 r11153  
    6767          bncoutf.h bncclockrinex.h bncsp3.h bncsinextro.h            \
    6868          bncbiassinex.h                                              \
    69           bncbytescounter.h bncsslconfig.h reqcdlg.h                  \
     69          bncbytescounter.h bncsslconfig.h bnccredentials.h reqcdlg.h                  \
    7070          ephemeris.h t_prn.h satObs.h                                \
    7171          upload/bncrtnetdecoder.h upload/bncuploadcaster.h           \
    … …  
    110110          bncbiassinex.cpp                                            \
    111111          ephemeris.cpp t_prn.cpp satObs.cpp                          \
    112           bncbytescounter.cpp bncsslconfig.cpp reqcdlg.cpp            \
     112          bncbytescounter.cpp bncsslconfig.cpp bnccredentials.cpp reqcdlg.cpp            \
    113113          upload/bncrtnetdecoder.cpp upload/bncuploadcaster.cpp       \
    114114          upload/bncrawuploadcaster.cpp                               \
  • trunk/BNC/src/upload/bncuploadcaster.cpp

    r11128 r11153  
    2222#include "bncsettings.h"
    2323#include "bncsslconfig.h"
     24#include "bnccredentials.h"
    2425
    2526using namespace std;
    … …  
    4647  _userName = userName;
    4748  _password = password;
     49  if (!_mountpoint.isEmpty() && !_casterOutHost.isEmpty()) {
     50    // empty password: from a credentials file, also without user (Ntrip Version 1)
     51    bncCredentials::complete(_casterOutHost, _casterOutPort, _userName, _password, true, true);
     52  }
    4853  _outSocket = 0;
    4954  _sOpenTrial = 0;
Note: See TracChangeset for help on using the changeset viewer.