1

我正在尝试调用 http 和 https 并尝试解析响应。我收到了对 http 调用的响应,但是对于 https 调用,我收到了这个错误

QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error




void MyClass::on_push_button_clicked()
{
QString address = "New York";

QNetworkAccessManager *qnam__get_address=NULL;
QNetworkRequest request;


QString myurl;
//myurl = "http://google.com/complete/search?output=toolbar&q="+address;
myurl = "https://maps.googleapis.com/maps/api/geocode/xml?address=New York&key=google api key";
QUrl url(myurl);
request.setUrl(url);
qDebug() << url;
qnam__get_address = new QNetworkAccessManager(this);
if(qnam__get_address) {
    QObject::connect(qnam__get_address, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), this, SLOT(onSslError(QNetworkReply*, QList<QSslError>)));
    QObject::connect(qnam__get_address, SIGNAL(finished(QNetworkReply*)),this, SLOT(on_push_button_clicked_response(QNetworkReply*)));
    reply = qnam__get_address->get(request);
}
return;
}
void MyClass::onSslError(QNetworkReply* r, QList<QSslError> errors) 
{
r->ignoreSslErrors();
}

void MyClass::on_push_button_clicked_response(QNetworkReply* reply)
{
// no error received?
if (reply->error() == QNetworkReply::NoError)
{
    qDebug()<<"MyClass:: got the response";
}
// Some http error received
else
{
    qDebug() << ".......error";
}
if(reply)
{
    reply->deleteLater();
}
return;
}

有人可以告诉我如何解决这个错误吗?我具体需要做什么?

我还观察到一种奇怪的行为,当我将 libeay32.dll 和 ssleay32.dll 文件与 .exe 文件一起保存时,我得到了 https 的响应,但没有得到 http 响应。

4

1 回答 1

1

愚蠢的高度............我安装了OpenSSL,它解决了这个问题。所以现在如果我尝试运行/调试它,我不会收到任何错误。

我找到了为什么这些 URL 不起作用。//myurl = " http://google.com:80/complete/search?output=toolbar&q= "+地址; myurl = " https://maps.googleapis.com:443/maps/api/geocode/xml?address=New York&key=google api key"; 添加端口后,我得到了响应。

于 2017-02-16T04:40:39.330 回答