Ignore:
Timestamp:
Jul 22, 2022, 1:34:16 PM (21 months ago)
Author:
stuerze
Message:

consideration of client SSL certificates, if they are available

File:
1 edited

Legend:

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

    r9757 r9795  
    7979      _secure = true;
    8080      _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);
    8184    }
    8285  }
     
    215218    _outSocket->ignoreSslErrors();
    216219  } 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);
    218234    connect(_outSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>)));
    219235  }
Note: See TracChangeset for help on using the changeset viewer.