试图忽略:
The host name did not match any of the valid hosts for this certificate
在QWebSocket::open()
:
QObject::connect(&sock,
&QWebSocket::sslErrors,
&sock,
static_cast<void(QWebSocket::*)(const QList<QSslError>&)>(&QWebSocket::ignoreSslErrors),
Qt::DirectConnection);
但错误仍在发生。怎么了?
答案 0 :(得分:0)
需要添加正常的回调,然后处理错误:
QObject::connect(&sock,
&QWebSocket::sslErrors,
this,
&MyClass::sslError,
Qt::DirectConnection);
...
void MyClass::sslError(const QList<QSslError>& errors)
{
// Here QWebSocket::ignoreSslErrors() can be called.
}