From 3d3fdcd3a588722b0004f4ef0c91f01ebc6c7b96 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 27 Nov 2011 12:45:30 +0000 Subject: Make the default ssloptions testable. Centralise the specification of the default ssloptions to make the code clearer and more testable. Change-Id: I4f4bae72736dd063ee4cd64c6375e82d0600a105 Reviewed-by: Peter Hartmann Reviewed-by: Shane Kearns --- src/network/ssl/qsslconfiguration.cpp | 5 ++++- src/network/ssl/qsslconfiguration_p.h | 4 +++- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp index 16486c957c..0e9eb5db62 100644 --- a/src/network/ssl/qsslconfiguration.cpp +++ b/src/network/ssl/qsslconfiguration.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE +const QSsl::SslOptions QSslConfigurationPrivate::defaultSslOptions = QSsl::SslOptionDisableEmptyFragments + |QSsl::SslOptionDisableLegacyRenegotiation; + /*! \class QSslConfiguration \brief The QSslConfiguration class holds the configuration and state of an SSL connection @@ -201,7 +204,7 @@ bool QSslConfiguration::isNull() const d->privateKey.isNull() && d->peerCertificate.isNull() && d->peerCertificateChain.count() == 0 && - d->sslOptions == (QSsl::SslOptionDisableEmptyFragments|QSsl::SslOptionDisableLegacyRenegotiation)); + d->sslOptions == QSslConfigurationPrivate::defaultSslOptions); } /*! diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h index a711eeb27f..59078ae7cc 100644 --- a/src/network/ssl/qsslconfiguration_p.h +++ b/src/network/ssl/qsslconfiguration_p.h @@ -83,7 +83,7 @@ public: : protocol(QSsl::SecureProtocols), peerVerifyMode(QSslSocket::AutoVerifyPeer), peerVerifyDepth(0), - sslOptions(QSsl::SslOptionDisableEmptyFragments|QSsl::SslOptionDisableLegacyRenegotiation) + sslOptions(QSslConfigurationPrivate::defaultSslOptions) { } QSslCertificate peerCertificate; @@ -101,6 +101,8 @@ public: QSsl::SslOptions sslOptions; + Q_AUTOTEST_EXPORT static const QSsl::SslOptions defaultSslOptions; + // in qsslsocket.cpp: static QSslConfiguration defaultConfiguration(); static void setDefaultConfiguration(const QSslConfiguration &configuration); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index e742c229c1..378aff924d 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -58,6 +58,7 @@ #ifndef QT_NO_OPENSSL #include "private/qsslsocket_openssl_p.h" #include "private/qsslsocket_openssl_symbols_p.h" +#include "private/qsslconfiguration_p.h" #endif #include "../../../network-settings.h" @@ -2080,6 +2081,10 @@ void tst_QSslSocket::sslOptions() if (!QSslSocket::supportsSsl()) return; + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, + QSslConfigurationPrivate::defaultSslOptions), + long(SSL_OP_ALL|SSL_OP_NO_SSLv2)); + QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols, QSsl::SslOptionDisableEmptyFragments |QSsl::SslOptionDisableLegacyRenegotiation), -- cgit v1.2.3