QNetworkAccessManager and HTTPS
-
Yes, it works as expected with http.
-
So your problem is solved :)
Then can you please update the thread title prepending [solved] so other forum users may know a solution has been found :)
-
Sorry, I don't understand how my problem is solved. It works with http, but I was testing it with images I don't want to download (a different unrelated website). The thumbnails I actually want to download are only available using https.
-
It seems we misunderstood each other.
Can you post the code you use to download the thumbnails ?
-
I don't have access to my work computer, so I put together a test that has the same results. You can use any image url that starts with https.
test.py
@
import sysfrom PyQt5.QtWidgets import *
from ThumbnailManager import ThumbnailManager
def main():
app = QApplication(sys.argv)thumbnailManager = ThumbnailManager()
urlString = r"https://developer.apple.com/design/awards/images/2014/icons/monument.jpg"
thumbnailManager.downloadThumbnail(urlString)sys.exit(app.exec_())
@ThumbnailManager.py
@
from PyQt5.QtCore import *
from PyQt5.QtNetwork import *class ThumbnailManager(QNetworkAccessManager):
def init(self):
super(ThumbnailManager, self).init()self.finished.connect(self.onFinished)
def downloadThumbnail(self, urlString):
url = QUrl(urlString)
request = QNetworkRequest(url)
self.get(request)@pyqtSlot(QNetworkReply)
def onFinished(self, reply):
print "onFinished"
if reply.error() != QNetworkReply.NoError:
print reply.error()
returnpixmap = QPixmap()
pixmap.loadFromData(reply.readAll())Do stuff with pixmap
@
prints:
onFinished
301 -
Hi,
I believe you need to have OpenSSL in your PATH.
Qt uses OpenSSL for SSL-related functions, including HTTPS. However, for legal reasons, it cannot be shipped with OpenSSL libraries. Thus, users need to install OpenSSL separately.
-
Thanks. I'm sure this works, but I'm a complete idiot when it comes to this kind of thing. I tried one of these http://slproweb.com/products/Win32OpenSSL.html and added C:\OpenSSL-Win64\bin to my Path, but it still doesn't work.
-
Some things to check:
You have installed 64-bit OpenSSL, which will work with 64-bit Qt apps. Is your Qt app 64-bit?
Have you tried restarting your PC after changing your PATH?
-
I'm pretty sure the application is using 64-bit Qt, but just to double check, I installed both 32-bit and 64-bit OpenSSL and tried with both. I checked the Path in command prompt to make sure it was set, and I also restarted my computer.
Just to be sure, does OpenSSL have to be compiled with Qt, or can I just add the necessary dll files without a recompile?
I was looking into it some more and it looks like libcrypto and libssl are the major libraries, but I don't see them in the bin folder. Are these the necessary dlls it needs? -
The official Qt packages try to load OpenSSL DLLs at runtime, so no recompilation of Qt is necessary.
I'm not familiar with how PyQt works though. Do you link your Python app with the official Qt libraries?
"This page":http://qt-project.org/doc/qt-5/ssl.html might contain a clue.
-
I'm pretty sure PyQt is just a layer on top of the Qt DLL files. After looking at that link, maybe the Qt version that was compiled used the -no-openssl flag. I can try asking the company about that. I appreciate all your help.
-
Yes, currently your best bet is to ask the provider. Good luck!