diff options
Diffstat (limited to 'src/network/ssl')
-rw-r--r-- | src/network/ssl/qsslcipher.cpp | 20 | ||||
-rw-r--r-- | src/network/ssl/qsslcipher.h | 1 | ||||
-rw-r--r-- | src/network/ssl/qsslsocket.cpp | 9 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp index cdb0ed9063..bb5d93e528 100644 --- a/src/network/ssl/qsslcipher.cpp +++ b/src/network/ssl/qsslcipher.cpp @@ -79,6 +79,26 @@ QSslCipher::QSslCipher() /*! Constructs a QSslCipher object for the cipher determined by \a + name. The constructor accepts only supported ciphers (i.e., the + \a name must identify a cipher in the list of ciphers returned by + QSslSocket::supportedCiphers()). + + You can call isNull() after construction to check if \a name + correctly identified a supported cipher. +*/ +QSslCipher::QSslCipher(const QString &name) + : d(new QSslCipherPrivate) +{ + foreach (const QSslCipher &cipher, QSslSocket::supportedCiphers()) { + if (cipher.name() == name) { + *this = cipher; + return; + } + } +} + +/*! + Constructs a QSslCipher object for the cipher determined by \a name and \a protocol. The constructor accepts only supported ciphers (i.e., the \a name and \a protocol must identify a cipher in the list of ciphers returned by diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h index e351d7949b..4cebffa7ae 100644 --- a/src/network/ssl/qsslcipher.h +++ b/src/network/ssl/qsslcipher.h @@ -57,6 +57,7 @@ class Q_NETWORK_EXPORT QSslCipher { public: QSslCipher(); + QSslCipher(const QString &name); QSslCipher(const QString &name, QSsl::SslProtocol protocol); QSslCipher(const QSslCipher &other); ~QSslCipher(); diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 0f934fa5d6..e107d94cf2 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1195,12 +1195,9 @@ void QSslSocket::setCiphers(const QString &ciphers) Q_D(QSslSocket); d->configuration.ciphers.clear(); foreach (const QString &cipherName, ciphers.split(QLatin1String(":"),QString::SkipEmptyParts)) { - for (int i = 0; i < 3; ++i) { - // ### Crude - QSslCipher cipher(cipherName, QSsl::SslProtocol(i)); - if (!cipher.isNull()) - d->configuration.ciphers << cipher; - } + QSslCipher cipher(cipherName); + if (!cipher.isNull()) + d->configuration.ciphers << cipher; } } |