我已经获得了CA签名证书,我将其用于Web服务。在Chrome和Firefox中,一切正常。
现在我想为webservice编写一个QT客户端。但我得到的只是30秒后“连接关闭”。如果我请求“https://gmail.com”或“https://www.dfn.de/”,我会得到正确的结果。
这是我的代码。
void Request::send() {
QUrl url("my url");
qDebug() << "URL: " << url;
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
QNetworkRequest request(url);
request.setHeader(QNetworkRequest::UserAgentHeader, userAgent);
QObject::connect(manager, &QNetworkAccessManager::authenticationRequired, this, &Request::provideAuthenication);
QObject::connect(manager, &QNetworkAccessManager::finished, this , &Request::replyFinished);
QObject::connect(manager, &QNetworkAccessManager::sslErrors, this , &Request::sslErrors);
qDebug() << "fire request";
manager->get(request);
}
void Request::provideAuthenication(QNetworkReply *, QAuthenticator *ator) {
qDebug() << "provideAuthenication";
ator->setUser("***");
ator->setPassword("***");
}
void Request::replyFinished(QNetworkReply *reply) {
if (reply->error() != QNetworkReply::NoError)
qDebug() << "Network Error: " << reply->errorString();
QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute );
QVariant statusPhrase = reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute );
qDebug() << "Result: " << statusCode.toInt() << " " << statusPhrase.toString();
qDebug() << "Data: " << reply->readAll();
}
void Request::sslErrors(QNetworkReply *, const QList<QSslError> &errors) {
foreach (const QSslError &error, errors) {
qDebug() << "SSL Error: " << error.errorString();
}
}
这就是输出。没有sslError!没有HTTP错误!
URL: QUrl( "my url" )
Network Error: "Connection closed"
Result: 0
Data: ""
那么为什么要挂QT或服务器呢?我错过了什么吗?!
答案 0 :(得分:0)
这是openjdk7(glassfish)的错误配置。
Aldaviva的暗示适用于 serverfault 。 https://serverfault.com/questions/389197/ssl-routinesssl23-writessl-handshake-failure
很糟糕,QT不会抛出ssl错误。