I'm writing a PyQt (Python bindings for the all-powerful Qt library) application and a small part of my application needs a web browser (hint, OAuth). So I started using QtWebkit, which is fantastic by the way. The only hitch is I would like to allow users behind a proxy to use my application.
I have read about the QNetworkProxy class in the QtNetwork package and figure it should do the trick. The only problem is when I create and apply the proxy, it works just fine over HTTP, but when I pass it a HTTPS (SSL) URL, it gives me the following errors:
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
Note: when I run...
QtNetwork.QSslSocket.supportsSsl()
.. it returns false. So that's proof of my problem.
Here's my main code (it's right before my creationg of my QApplication):
proxy = QtNetwork.QNetworkProxy()
proxy.setType(QtNetwork.QNetworkProxy.Socks5Proxy)
proxy.setHostName('localhost');
proxy.setPort(1337)
QtNetwork.QNetworkProxy.setApplicationProxy(proxy);
I got the code from here but the example was written in C++, not Python so I'm not quite sure if I translated it properly. That could be the problem.
EDIT: I've tried it over a SOCKS5 and an HTTP proxy and they both throw the same error.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With