2011-05-09 48 views
3

我編寫了一個使用OpenSSL的應用程序qt。從昨天開始,一切都很好。我編譯了應用程序併發送給我的朋友。在他的電腦上應用程序可以打開https。我在其他計算機上打開,它不起作用。所以我把它給了其他朋友,他無法打開https網站。我很困惑,並給了其他人,並在他的電腦上我的應用程序正在工作。我不瞭解情況。以前的版本沒有bug。但我跑了以前的版本,它工作,它不工作。我關掉了所有的防火牆。沒有改變。Qt OpenSSL問題 - 在某些計算機上阻塞(?)

有什麼建議嗎?

我們都有7 x64。我測試了XP HE,它工作,7 x64上的bou不起作用。在我的朋友的電腦上7 x64的作品,但在XP上,他不工作。 IMO操作系統沒有任何意義。

+1

如果您詳細說明您的意思是「不起作用」,這將有所幫助。一個特定的錯誤會很有用。 – 2011-05-09 19:12:56

+0

https未加載。當我向SSL頁面發送請求時,它返回空白頁面。我的故事,我沒有解釋「不起作用」 – RzuF 2011-05-09 20:15:19

回答

2

默認情況下,Qt不包含OpenSSL的實現,但使用已經安裝到系統中的庫。

安裝Win32 OpenSSL將使其工作。

另一個選擇是用OpenSSL構建Qt。一些信息here

+0

我用OpenSSL構建Qt。更多關於我的電腦OpenSSL已安裝,但我的應用程序無法正常工作。 – RzuF 2011-05-11 12:26:45

2

如果你仍然沒有解決方案的錯誤 - 我剛剛跑過同樣的問題。這似乎是Windows計算機上CA證書鏈的問題。詳細信息請見https://bugreports.qt-project.org/browse/QTBUG-20012

這裏也是一個小類,它修復了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 
相關問題