PyQt5 QNetworkAccesManager SSL error

0

I have a problem that I do not have with the solution, I am trying to access a site (https) using QNetworkAccesManager, I am Using PyQt5 (compiled by me) in Python 2.7.14 32Bit

my code is this:

from PyQt5.QtCore import QUrl, QCoreApplication
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply

app = QCoreApplication([])
nam = QNetworkAccessManager()
req = QNetworkRequest(QUrl('https://www.google.es'))
resp = nam.get(req)


def downloadProgress(bytesReceived, bytesTotal):
    print 'Descargado: %s de %s' %  (bytesReceived, bytesTotal)


def sslErrors(errors):
    for error in errors:
        print error.errorString()


resp.sslErrors.connect(sslErrors)
resp.downloadProgress.connect(downloadProgress)
app.exec_()

and this is what it shows me in the console:

The host name did not match any of the valid hosts for this certificate
The signature of the certificate is invalid
The signature of the certificate is invalid
Descargado: 0 de 0

Any suggestions? I've tried everything I've seen out there but nothing seems to work.

EDIT:

I add this information in case it clarifies something:

>>> from PyQt5.QtNetwork import QSslSocket
>>> QSslSocket.supportsSsl()
qt.network.ssl: QSslSocket: cannot resolve ERR_peek_last_error
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
qt.network.ssl: QSslSocket: cannot resolve CONF_get1_default_config_file
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
qt.network.ssl: QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
qt.network.ssl: QSslSocket: cannot resolve EC_KEY_get0_group
qt.network.ssl: QSslSocket: cannot resolve EC_GROUP_get_degree
qt.network.ssl: QSslSocket: cannot resolve EVP_CIPHER_CTX_new
qt.network.ssl: QSslSocket: cannot resolve EVP_CIPHER_CTX_free
qt.network.ssl: QSslSocket: cannot resolve EVP_CipherInit_ex
qt.network.ssl: QSslSocket: cannot resolve EVP_PKEY_set1_EC_KEY
qt.network.ssl: QSslSocket: cannot resolve EVP_PKEY_get1_EC_KEY
qt.network.ssl: QSslSocket: cannot resolve PEM_read_bio_ECPrivateKey
qt.network.ssl: QSslSocket: cannot resolve PEM_write_bio_ECPrivateKey
qt.network.ssl: QSslSocket: cannot resolve PEM_read_bio_EC_PUBKEY
qt.network.ssl: QSslSocket: cannot resolve PEM_write_bio_EC_PUBKEY
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_server_callback
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_use_psk_identity_hint
qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
qt.network.ssl: QSslSocket: cannot resolve SSL_set_alpn_protos
qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_alpn_select_cb
qt.network.ssl: QSslSocket: cannot resolve SSL_get0_alpn_selected
qt.network.ssl: QSslSocket: cannot resolve EC_KEY_dup
qt.network.ssl: QSslSocket: cannot resolve EC_KEY_new_by_curve_name
qt.network.ssl: QSslSocket: cannot resolve EC_KEY_free
qt.network.ssl: QSslSocket: cannot resolve EC_get_builtin_curves
qt.network.ssl: QSslSocket: cannot call unresolved function CONF_get1_default_config_file
qt.network.ssl: QSslSocket: cannot call unresolved function OPENSSL_add_all_algorithms_conf
True

Ok, I have already found the solution with the Qt compiled version and the one that was installed in the system did not match

QSslSocket.sslLibraryVersionString()
QSslSocket.sslLibraryBuildVersionString()

I had to update the files libeay32.dll and ssleay32.dll of C:\Windows\SysWOW64 but my question is, can I tell Qt the openssl path if I want to use a different version than the one I have installed on the system?

    
asked by divadr 06.04.2018 в 01:07
source

1 answer

1

What is happening to you is that the Qt libraries you are using link to openssl ... in a dynamic way. This means that you must have the openssl DLLs available on your computer and localized by Qt.

The most normal thing is that you have to find a version of openSSL compatible with the one expected by Qt or mount it by your own means (if they do not tell you anything, the best thing is to mount the latest stable version).

To avoid interference with other possible versions of the library, it is best to place your DLLs next to the executable, since that is where you first try to find the libraries.

This solution will prevent you from forgetting to take the DLLs with you when you take the executable to another computer.

    
answered by 06.04.2018 в 09:32