Changeset 11126 in ntrip for trunk/BNC/src/upload


Ignore:
Timestamp:
Oct 24, 2026, 11:14:36 PM (13 days ago)
Author:
stuerze
Message:

Some fixes from security point of view

Location:
trunk/BNC/src/upload
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/upload/bncrtnetuploadcaster.cpp

    r11124 r11126  
    10681068    // -----------
    10691069    QByteArray hlpBufferServiceCrs;
    1070     if (sizeof(serviceCrs._name) > 0) {
     1070    if (serviceCrs._name[0]) { // no CRS messages for a custom transformation
    10711071        if (fmod(epoTime.gpssec(), _samplRtcmCrs) == 0.0) {
    10721072            memset(obuffer, 0, sizeof(obuffer));
    … …  
    10811081    // --------
    10821082    QByteArray hlpBufferRtcmCrs;
    1083     if (sizeof(rtcmCrs._name) > 0) {
     1083    if (rtcmCrs._name[0]) {
    10841084        if (fmod(epoTime.gpssec(), _samplRtcmCrs) == 0.0) {
    10851085            memset(obuffer, 0, sizeof(obuffer));
  • trunk/BNC/src/upload/bncuploadcaster.cpp

    r10753 r11126  
    8080  if (_ntripVersion == "2s") {
    8181    if (!QSslSocket::supportsSsl()) {
    82       emit(newMessage(
    83           "For SSL support please install OpenSSL run-time libraries: Ntrip Version 2 is tried",
    84           true));
    85       _ntripVersion == "2";
     82      // no fallback to Ntrip Version 2: user name and password would be sent
     83      // unencrypted although an encrypted connection was configured
     84      emit(newMessage(_mountpoint.toLatin1() + "@" + _casterOutHost.toLatin1() +
     85          ": No SSL support, please install OpenSSL run-time libraries: no upload", true));
    8686    } else {
    8787      _secure = true;
    … …  
    150150      const QSslError& err = it.next();
    151151      msg += err.errorString();
    152     }
    153     emit(newMessage(msg.toLatin1(), true));
     152      if (it.hasNext()) {
     153        msg += "; ";
     154      }
     155    }
     156    if (_sslIgnoreErrors) {
     157      _outSocket->ignoreSslErrors();
     158      msg += " (ignored as configured)";
     159    }
     160    emit(newMessage(_mountpoint.toLatin1() + "@" + _casterOutHost.toLatin1() + ": " + msg.toLatin1(), true));
    154161  }
    155162}
    … …  
    203210  }
    204211
     212  if (_ntripVersion == "2s" && !_secure) { // no SSL support, see constructor
     213    return;
     214  }
     215
    205216  if (_outSocket != 0 &&
    206217      _outSocket->state() == QAbstractSocket::ConnectedState) {
    … …  
    224235  _outSocket->setProxy(QNetworkProxy::NoProxy);
    225236
    226   if (_sslIgnoreErrors) {
    227     _outSocket->ignoreSslErrors();
    228   } else {
    229     bncSslConfig sslConfig = BNC_SSL_CONFIG;
    230     QFile clientCrtFile(_crtFileName);
    231     QFile privateKeyFile(_keyFileName);
    232     if ( clientCrtFile.exists() && privateKeyFile.exists()) {
    233       // set local certificate
    234       clientCrtFile.open(QIODevice::ReadOnly);
    235       QSslCertificate clientCrt(&clientCrtFile);
    236       sslConfig.setLocalCertificate(clientCrt);
    237       // set private key if available
    238       privateKeyFile.open(QIODevice::ReadOnly);
    239       QSslKey privateKey(&privateKeyFile, QSsl::Rsa);
    240       sslConfig.setPrivateKey(privateKey);
    241     }
    242     _outSocket->setSslConfiguration(sslConfig);
    243     connect(_outSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
    244   }
     237  bncSslConfig sslConfig = BNC_SSL_CONFIG;
     238  QFile clientCrtFile(_crtFileName);
     239  QFile privateKeyFile(_keyFileName);
     240  if ( clientCrtFile.exists() && privateKeyFile.exists()) {
     241    // set local certificate
     242    clientCrtFile.open(QIODevice::ReadOnly);
     243    QSslCertificate clientCrt(&clientCrtFile);
     244    sslConfig.setLocalCertificate(clientCrt);
     245    // set private key if available
     246    privateKeyFile.open(QIODevice::ReadOnly);
     247    QSslKey privateKey(&privateKeyFile, QSsl::Rsa);
     248    sslConfig.setPrivateKey(privateKey);
     249  }
     250  _outSocket->setSslConfiguration(sslConfig);
     251  // Direct connection: the socket lives in this thread, the caster object in
     252  // the main thread. The slot must run during the handshake, both for
     253  // ignoreSslErrors() to take effect and to access _outSocket safely.
     254  connect(_outSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)),
     255          Qt::DirectConnection);
    245256
    246257  if (!_proxy) {
Note: See TracChangeset for help on using the changeset viewer.