zoukankan      html  css  js  c++  java
  • Qt https 用户认证authenticationRequired()

    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<QSslError>)),
                this, SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
    #endif
    
    
    #ifndef QT_NO_SSL
    void MainWindow::sslErrors(QNetworkReply *reply,const QList<QSslError> &)
    {
        reply->ignoreSslErrors();
    }
    #endif
    
    解决问题

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

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

  • 相关阅读:
    Codeforces Round #439 (Div. 2)
    Money Systems
    Stamps
    inflate
    多重背包问题
    AIM Tech Round 4 (Div. 2)
    September Challenge 2017
    树的重心
    百度之星2017初赛A
    树上的最大独立集
  • 原文地址:https://www.cnblogs.com/findumars/p/6404098.html
Copyright © 2011-2022 走看看