Qt https 用户认证authenticationRequired()

admin 2022年6月27日08:10:08评论155 views字数 1043阅读3分28秒阅读模式

用QNetworkAccessManager以POST方式访问https
需要用户认证,所以用

SIGNAL(authenticationRequired(QNetworkReply *, QAuthenticator *))
manager = new QNetworkAccessManager(this); connect(manager,SIGNAL(authenticationRequired(QNetworkReply *, QAuthenticator *)), this, SLOT(onAuthenticationRequest(QNetworkReply *, QAuthenticator *)));


以POST访问

    QByteArray postdata;       reply = manager->post(QNetworkRequest(url), postdata);


却不会运行SLOT(onAuthenticationRequest(QNetworkReply *, QAuthenticator *))


怎么也查不出原因


用wget 
https://xxx.xxxxx.xxx/xxxx  --no-check-certificate --post-data="" --user=username --password=pass
可以正确获取

-----------------------------------------------------------------------------

加上

#ifndef QT_NO_SSL    connect(manager, SIGNAL(sslErrors(QNetworkReply*,QList)),            this, SLOT(sslErrors(QNetworkReply*,QList)));#endif#ifndef QT_NO_SSLvoid MainWindow::sslErrors(QNetworkReply *reply,const QList &){    reply->ignoreSslErrors();}#endif解决问题

 刚想说,发现你自己解决了,反正就是因为qt自己没有**验证的功能,会出现ssl的错误,也可以自己带**来完成验证

http://www.qter.org/forum.php?mod=viewthread&tid=5762&extra=page%3D1

Qt https 用户认证authenticationRequired()


原文始发于微信公众号(汇编语言):Qt https 用户认证authenticationRequired()

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月27日08:10:08
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Qt https 用户认证authenticationRequired()https://cn-sec.com/archives/1145329.html

发表评论

匿名网友 填写信息