Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt OpenSSL问题-在某些计算机上被阻止(?)_Qt_Ssl_Webkit_Openssl_Qtnetwork - Fatal编程技术网

Qt OpenSSL问题-在某些计算机上被阻止(?)

Qt OpenSSL问题-在某些计算机上被阻止(?),qt,ssl,webkit,openssl,qtnetwork,Qt,Ssl,Webkit,Openssl,Qtnetwork,我编写了一个应用程序I qt,它使用OpenSSL。从昨天起,一切都很好。我编译了应用程序并发送给我的朋友。在他的计算机上,应用程序可以打开https。我在另一台计算机上打开,但它不工作。所以我把它给了另一个朋友,他不能打开https网站。我很困惑,给了另一个人,在他的电脑上我的应用程序正在运行。我不理解这种情况。以前的版本没有bug。但我运行的是以前的版本,它工作正常,但也不工作。我关掉了所有的防火墙。没有什么变化 有什么建议吗 我们都有7个x64。我在XP上进行了测试,他成功了,但7 x64

我编写了一个应用程序I qt,它使用OpenSSL。从昨天起,一切都很好。我编译了应用程序并发送给我的朋友。在他的计算机上,应用程序可以打开https。我在另一台计算机上打开,但它不工作。所以我把它给了另一个朋友,他不能打开https网站。我很困惑,给了另一个人,在他的电脑上我的应用程序正在运行。我不理解这种情况。以前的版本没有bug。但我运行的是以前的版本,它工作正常,但也不工作。我关掉了所有的防火墙。没有什么变化

有什么建议吗


我们都有7个x64。我在XP上进行了测试,他成功了,但7 x64上的bou不成功。在我朋友的电脑上,7x64可以工作,但在XP上他不工作。IMO操作系统并没有任何意义。

默认情况下,Qt不包含OpenSSL的实现,而是使用系统中已经安装的库

安装将使它工作

另一个选择是使用OpenSSL构建Qt。一些信息。

尝试使用该方法


我也遇到过这样的问题,使用此函数为我解决了这些问题。

如果您仍然无法解决此错误,我只是重复了相同的问题。Windows计算机上的CA证书链似乎有问题。详情请浏览

这里还有一个修复ca链的小类,这样应用程序中就不会出现错误

#ifndef OPENSSLFIX_H
#define OPENSSLFIX_H

#include <QSslConfiguration>

/* this class fixes a problem with qt/openssl and expired ca certificates.
 * the idea is taken from https://bugreports.qt-project.org/browse/QTBUG-20012
 * which describes the problem and the workaround further. the workaround is
 * scheduled for qt5, but will not be introduced into qt4.x.
 *
 * to use this fix just call it in main() before doing any network related 
 * stuff
 *
 * OpenSslFix::fixCaCertificates();
 *
 * it will go through the certificates and remove invalid certs from the chain,
 * thus avoiding the error to arise.
 */
class OpenSslFix {
public:
    static void fixCaCertificates()
    {
        QSslConfiguration config(QSslConfiguration::defaultConfiguration());
        QList<QSslCertificate> in(config.caCertificates());
        QList<QSslCertificate> out;

        for (int i=0, size=in.size(); i<size; ++i) {
            const QSslCertificate &c(in[i]);
            if (c.isValid()) {
                /* not expired -> add */
                out << c;
                continue;
            }

            /* check if the cert is already present in the output */
            bool found = false;
            for (int j=0, size=out.size(); j<size; ++j) {
                if (isCertificateSameName(c, out[j])) {
                    /* already present... */
                    found = true;
                    break;
                }
            }

            if (!found)
                out << c;
        }

        /* now set the new list as the default */
        config.setCaCertificates(out);
        QSslConfiguration::setDefaultConfiguration(config);
    }

private:
    static inline bool isCertificateSameName(const QSslCertificate &cert1, 
                                             const QSslCertificate &cert2)
    {
        return cert1.subjectInfo(QSslCertificate::Organization) ==
                cert2.subjectInfo(QSslCertificate::Organization) &&
                cert1.subjectInfo(QSslCertificate::CommonName) ==
                cert2.subjectInfo(QSslCertificate::CommonName) &&
                cert1.subjectInfo(QSslCertificate::LocalityName) ==
                cert2.subjectInfo(QSslCertificate::LocalityName) &&
                cert1.subjectInfo(QSslCertificate::OrganizationalUnitName) ==
                cert2.subjectInfo(QSslCertificate::OrganizationalUnitName) &&
                cert1.subjectInfo(QSslCertificate::StateOrProvinceName) ==
                cert2.subjectInfo(QSslCertificate::StateOrProvinceName) &&
                cert1.subjectInfo(QSslCertificate::CountryName) ==
                cert2.subjectInfo(QSslCertificate::CountryName);
    }
};

#endif // OPENSSLFIX_H
\ifndef OPENSSLFIX\u H
#定义OPENSSLFIX_H
#包括
/*此类修复了qt/openssl和过期ca证书的问题。
*这个想法来源于https://bugreports.qt-project.org/browse/QTBUG-20012
*这进一步描述了问题和解决方法。解决办法是
*计划用于qt5,但不会引入qt4.x。
*
*要使用此修复程序,只需在main()中调用它,然后再执行任何与网络相关的操作
*东西
*
*OpenSslFix::fixCaCertificates();
*
*它将检查证书并从链中删除无效证书,
*从而避免出现错误。
*/
类OpenSslFix{
公众:
静态无效固定证书()
{
QSslConfiguration配置(QSslConfiguration::defaultConfiguration());
(config.caCertificates())中的QList;
QList out;
对于(int i=0,size=in.size();我添加*/

如果你详细说明“不工作”的含义,它会有所帮助。一个特定的错误会很有用。https不会加载。当我向SSL页面发送请求时,它会返回空白页面。我的faut,我没有解释“不工作”,我用OpenSSL构建了Qt。更重要的是,我的PC上安装了OpenSSL,但我的应用程序在上面不工作。