5

我正在编写一个 PyQt(功能强大的 Qt 库的 Python 绑定)应用程序,我的应用程序的一小部分需要一个 Web 浏览器(提示,OAuth)。所以我开始使用 QtWebkit,顺便说一句,这太棒了。唯一的障碍是我想允许代理后面的用户使用我的应用程序。

我已经阅读了 QtNetwork 包中的 QNetworkProxy 类,并认为它应该可以解决问题。唯一的问题是当我创建和应用代理时,它在 HTTP 上工作得很好,但是当我将它传递给 HTTPS (SSL) URL 时,它给了我以下错误:

QSslSocket: cannot call unresolved function SSLv3_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
QSslSocket: cannot call unresolved function ERR_error_string

注意:当我跑...

QtNetwork.QSslSocket.supportsSsl()

..它返回假。所以这证明了我的问题。

这是我的主要代码(就在我创建 QApplication 之前):

proxy = QtNetwork.QNetworkProxy()
proxy.setType(QtNetwork.QNetworkProxy.Socks5Proxy)
proxy.setHostName('localhost');
proxy.setPort(1337)
QtNetwork.QNetworkProxy.setApplicationProxy(proxy);

我从这里得到了代码,但是这个例子是用 C++ 编写的,而不是 Python,所以我不太确定我是否正确地翻译了它。这可能是问题所在。

编辑:我已经通过 SOCKS5 和 HTTP 代理进行了尝试,它们都抛出了相同的错误。

4

1 回答 1

6

I was working on Windows XP (32-bit) with Python 2.6 and PyQt 4.7.4. The reason that...

QtNetwork.QSslSocket.supportsSsl()

was returning false was because I had not installed OpenSSL binaries to my system.

To solve the problem I went here to download the binaries. Before they would properly install I had to also get the Visual C++ 2008 Redistributables install from Microsoft.

Everything is working great now!

于 2010-08-10T12:19:10.327 回答