From 7106ffb0394c4919da57716a2f877e8ccb3f19f6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 19 Feb 2015 14:19:18 +0100 Subject: [PATCH] QSslSocket: Factor out error message about failure to set the elliptic curves. Change-Id: Ic5305216536ee3938c389336c979b5c90fc886e4 Reviewed-by: Marc Mutz --- src/network/ssl/qsslcontext_openssl.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp index f30f77d2069..a7295933b5e 100644 --- a/src/network/ssl/qsslcontext_openssl.cpp +++ b/src/network/ssl/qsslcontext_openssl.cpp @@ -86,6 +86,11 @@ QSslContext::~QSslContext() q_SSL_SESSION_free(session); } +static inline QString msgErrorSettingEllipticCurves(const QString &why) +{ + return QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(why); +} + QSslContext* QSslContext::fromConfiguration(QSslSocket::SslMode mode, const QSslConfiguration &configuration, bool allowRootCertOnDemandLoading) { QSslContext *sslContext = new QSslContext(); @@ -342,7 +347,7 @@ init_context: SSL_CTRL_SET_CURVES, qcurves.size(), const_cast(reinterpret_cast(qcurves.data())))) { - sslContext->errorStr = QSslSocket::tr("Error when setting the elliptic curves (%1)").arg(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); + sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); sslContext->errorCode = QSslError::UnspecifiedError; return sslContext; } @@ -350,7 +355,7 @@ init_context: #endif // OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC) { // specific curves requested, but not possible to set -> error - sslContext->errorStr = QSslSocket::tr("Error when setting the elliptic curves (OpenSSL version too old, need at least v1.0.2)"); + sslContext->errorStr = msgErrorSettingEllipticCurves(QSslSocket::tr("OpenSSL version too old, need at least v1.0.2")); sslContext->errorCode = QSslError::UnspecifiedError; return sslContext; }