DTLS - treat QSslSocket::UnencryptedMode as invalid

Unfortunately, this enum is not 'binary', it also has 'UnencryptedMode'
and as a result we can end up with server-side method/context.

Change-Id: If2da4c1b9f7e9ff916d933c9517c00a632aea324
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
bb10
Timur Pocheptsov 2018-07-27 14:34:32 +02:00
parent 8a450f570b
commit 28503387ea
1 changed files with 6 additions and 0 deletions

View File

@ -715,6 +715,12 @@ bool DtlsState::initCtxAndConnection(QDtlsBasePrivate *dtlsBase)
Q_ASSERT(dtlsBase);
Q_ASSERT(QSslSocket::supportsSsl());
if (dtlsBase->mode == QSslSocket::UnencryptedMode) {
dtlsBase->setDtlsError(QDtlsError::TlsInitializationError,
QDtls::tr("Invalid SslMode, SslServerMode or SslClientMode expected"));
return false;
}
// create a deep copy of our configuration
auto configurationCopy = new QSslConfigurationPrivate(dtlsBase->dtlsConfiguration);
configurationCopy->ref.store(0); // the QSslConfiguration constructor refs up