QSslSocket: deprecate sslErrors() getter
To disambiguate &QSslSocket::sslErrors() expression. Add a new getter - sslHandshakeErrors(). [ChangeLog][Deprecation Notice] QSslSocket::sslErrors() (the getter) was deprecated and superseded by sslHandshakeErrors() Task-number: QTBUG-80369 Change-Id: I9dcca3c8499800c122db230753dc19b07654f8a2 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
69e7dfdb28
commit
76c4c5d558
@ -289,7 +289,7 @@
|
|||||||
If you want to continue connecting despite the errors that have occurred,
|
If you want to continue connecting despite the errors that have occurred,
|
||||||
you must call QSslSocket::ignoreSslErrors() from inside a slot connected to
|
you must call QSslSocket::ignoreSslErrors() from inside a slot connected to
|
||||||
this signal. If you need to access the error list at a later point, you
|
this signal. If you need to access the error list at a later point, you
|
||||||
can call sslErrors() (without arguments).
|
can call sslHandshakeErrors().
|
||||||
|
|
||||||
\a errors contains one or more errors that prevent QSslSocket from
|
\a errors contains one or more errors that prevent QSslSocket from
|
||||||
verifying the identity of the peer.
|
verifying the identity of the peer.
|
||||||
@ -1825,7 +1825,28 @@ bool QSslSocket::waitForDisconnected(int msecs)
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
/*!
|
/*!
|
||||||
|
\deprecated
|
||||||
|
|
||||||
|
Use sslHandshakeErrors() instead.
|
||||||
|
|
||||||
|
Returns a list of the last SSL errors that occurred. This is the
|
||||||
|
same list as QSslSocket passes via the sslErrors() signal. If the
|
||||||
|
connection has been encrypted with no errors, this function will
|
||||||
|
return an empty list.
|
||||||
|
|
||||||
|
\sa connectToHostEncrypted(), sslHandshakeErrors()
|
||||||
|
*/
|
||||||
|
QList<QSslError> QSslSocket::sslErrors() const
|
||||||
|
{
|
||||||
|
return sslHandshakeErrors();
|
||||||
|
}
|
||||||
|
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\since 5.15
|
||||||
|
|
||||||
Returns a list of the last SSL errors that occurred. This is the
|
Returns a list of the last SSL errors that occurred. This is the
|
||||||
same list as QSslSocket passes via the sslErrors() signal. If the
|
same list as QSslSocket passes via the sslErrors() signal. If the
|
||||||
connection has been encrypted with no errors, this function will
|
connection has been encrypted with no errors, this function will
|
||||||
@ -1833,7 +1854,7 @@ bool QSslSocket::waitForDisconnected(int msecs)
|
|||||||
|
|
||||||
\sa connectToHostEncrypted()
|
\sa connectToHostEncrypted()
|
||||||
*/
|
*/
|
||||||
QList<QSslError> QSslSocket::sslErrors() const
|
QList<QSslError> QSslSocket::sslHandshakeErrors() const
|
||||||
{
|
{
|
||||||
Q_D(const QSslSocket);
|
Q_D(const QSslSocket);
|
||||||
return d->sslErrors;
|
return d->sslErrors;
|
||||||
@ -2035,7 +2056,7 @@ void QSslSocket::ignoreSslErrors()
|
|||||||
You can clear the list of errors you want to ignore by calling this
|
You can clear the list of errors you want to ignore by calling this
|
||||||
function with an empty list.
|
function with an empty list.
|
||||||
|
|
||||||
\sa sslErrors()
|
\sa sslErrors(), sslHandshakeErrors()
|
||||||
*/
|
*/
|
||||||
void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
|
void QSslSocket::ignoreSslErrors(const QList<QSslError> &errors)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,10 @@ public:
|
|||||||
bool waitForBytesWritten(int msecs = 30000) override;
|
bool waitForBytesWritten(int msecs = 30000) override;
|
||||||
bool waitForDisconnected(int msecs = 30000) override;
|
bool waitForDisconnected(int msecs = 30000) override;
|
||||||
|
|
||||||
QList<QSslError> sslErrors() const;
|
#if QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QT_DEPRECATED_X("Use sslHandshakeErrors()") QList<QSslError> sslErrors() const;
|
||||||
|
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||||
|
QList<QSslError> sslHandshakeErrors() const;
|
||||||
|
|
||||||
static bool supportsSsl();
|
static bool supportsSsl();
|
||||||
static long sslLibraryVersionNumber();
|
static long sslLibraryVersionNumber();
|
||||||
|
@ -431,14 +431,14 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define QCOMPARE_SINGLE_ERROR(sslSocket, expectedError) \
|
#define QCOMPARE_SINGLE_ERROR(sslSocket, expectedError) \
|
||||||
const auto &tlsErrors = sslSocket.sslErrors(); \
|
const auto &tlsErrors = sslSocket.sslHandshakeErrors(); \
|
||||||
QCOMPARE(tlsErrors.size(), 1); \
|
QCOMPARE(tlsErrors.size(), 1); \
|
||||||
QCOMPARE(tlsErrors[0].error(), expectedError)
|
QCOMPARE(tlsErrors[0].error(), expectedError)
|
||||||
|
|
||||||
#define QVERIFY_HANDSHAKE_WITHOUT_ERRORS(sslSocket) \
|
#define QVERIFY_HANDSHAKE_WITHOUT_ERRORS(sslSocket) \
|
||||||
QVERIFY(sslSocket.isEncrypted()); \
|
QVERIFY(sslSocket.isEncrypted()); \
|
||||||
QCOMPARE(sslSocket.state(), QAbstractSocket::ConnectedState); \
|
QCOMPARE(sslSocket.state(), QAbstractSocket::ConnectedState); \
|
||||||
QVERIFY(sslSocket.sslErrors().isEmpty())
|
QVERIFY(sslSocket.sslHandshakeErrors().isEmpty())
|
||||||
|
|
||||||
#define QDECLARE_CHAIN(object, chainFileName) \
|
#define QDECLARE_CHAIN(object, chainFileName) \
|
||||||
CertificateChain object = QSslCertificate::fromPath(certDirPath + QLatin1String(chainFileName)); \
|
CertificateChain object = QSslCertificate::fromPath(certDirPath + QLatin1String(chainFileName)); \
|
||||||
@ -722,7 +722,7 @@ void tst_QOcsp::wrongCertificateInResponse()
|
|||||||
loop.enterLoopMSecs(handshakeTimeoutMS);
|
loop.enterLoopMSecs(handshakeTimeoutMS);
|
||||||
|
|
||||||
QVERIFY(!clientSocket.isEncrypted());
|
QVERIFY(!clientSocket.isEncrypted());
|
||||||
QVERIFY(containsError(clientSocket.sslErrors(), expectedError));
|
QVERIFY(containsError(clientSocket.sslHandshakeErrors(), expectedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QOcsp::untrustedResponder()
|
void tst_QOcsp::untrustedResponder()
|
||||||
@ -747,7 +747,7 @@ void tst_QOcsp::untrustedResponder()
|
|||||||
loop.enterLoopMSecs(handshakeTimeoutMS);
|
loop.enterLoopMSecs(handshakeTimeoutMS);
|
||||||
|
|
||||||
QVERIFY(!clientSocket.isEncrypted());
|
QVERIFY(!clientSocket.isEncrypted());
|
||||||
QVERIFY(containsError(clientSocket.sslErrors(), expectedError));
|
QVERIFY(containsError(clientSocket.sslHandshakeErrors(), expectedError));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QOcsp::setupOcspClient(QSslSocket &clientSocket, const CertificateChain &caCerts, const QString &name)
|
void tst_QOcsp::setupOcspClient(QSslSocket &clientSocket, const CertificateChain &caCerts, const QString &name)
|
||||||
|
@ -732,7 +732,7 @@ void tst_QSslSocket::sslErrors()
|
|||||||
// check the SSL errors contain HostNameMismatch and an error due to
|
// check the SSL errors contain HostNameMismatch and an error due to
|
||||||
// the certificate being self-signed
|
// the certificate being self-signed
|
||||||
SslErrorList sslErrors;
|
SslErrorList sslErrors;
|
||||||
const auto socketSslErrors = socket->sslErrors();
|
const auto socketSslErrors = socket->sslHandshakeErrors();
|
||||||
for (const QSslError &err : socketSslErrors)
|
for (const QSslError &err : socketSslErrors)
|
||||||
sslErrors << err.error();
|
sslErrors << err.error();
|
||||||
std::sort(sslErrors.begin(), sslErrors.end());
|
std::sort(sslErrors.begin(), sslErrors.end());
|
||||||
@ -2432,7 +2432,7 @@ void tst_QSslSocket::verifyMode()
|
|||||||
|
|
||||||
QList<QSslError> expectedErrors = QList<QSslError>()
|
QList<QSslError> expectedErrors = QList<QSslError>()
|
||||||
<< QSslError(FLUKE_CERTIFICATE_ERROR, socket.peerCertificate());
|
<< QSslError(FLUKE_CERTIFICATE_ERROR, socket.peerCertificate());
|
||||||
QCOMPARE(socket.sslErrors(), expectedErrors);
|
QCOMPARE(socket.sslHandshakeErrors(), expectedErrors);
|
||||||
socket.abort();
|
socket.abort();
|
||||||
|
|
||||||
VerifyServer server;
|
VerifyServer server;
|
||||||
@ -2448,7 +2448,7 @@ void tst_QSslSocket::verifyMode()
|
|||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
QVERIFY(clientSocket.isEncrypted());
|
QVERIFY(clientSocket.isEncrypted());
|
||||||
QVERIFY(server.socket->sslErrors().isEmpty());
|
QVERIFY(server.socket->sslHandshakeErrors().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSslSocket::verifyDepth()
|
void tst_QSslSocket::verifyDepth()
|
||||||
@ -2825,7 +2825,7 @@ void tst_QSslSocket::blacklistedCertificates()
|
|||||||
connect(receiver, SIGNAL(sslErrors(QList<QSslError>)), SLOT(exitLoop()));
|
connect(receiver, SIGNAL(sslErrors(QList<QSslError>)), SLOT(exitLoop()));
|
||||||
connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop()));
|
connect(receiver, SIGNAL(encrypted()), SLOT(exitLoop()));
|
||||||
enterLoop(1);
|
enterLoop(1);
|
||||||
QList<QSslError> sslErrors = receiver->sslErrors();
|
QList<QSslError> sslErrors = receiver->sslHandshakeErrors();
|
||||||
QVERIFY(sslErrors.count() > 0);
|
QVERIFY(sslErrors.count() > 0);
|
||||||
// there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error
|
// there are more errors (self signed cert and hostname mismatch), but we only care about the blacklist error
|
||||||
QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted);
|
QCOMPARE(sslErrors.at(0).error(), QSslError::CertificateBlacklisted);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user