Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

HTTPS request error while using network proxy



  • hi,
    I want to analyze https stream data. I create a proxy server by QTcpServer and QSslSocket, but after I set up proxy to my server and request www.example.com, I got ssl error:

    	m_networkManager = new QNetworkAccessManager(this);
    	QNetworkProxy proxy(QNetworkProxy::HttpProxy);
    	proxy.setHostName(proxyHost);
    	proxy.setPort(9999);
    	m_networkManager->setProxy(proxy);
    
    	QNetworkConfiguration networkConfiguration = m_networkManager->configuration();
    	networkConfiguration.setConnectTimeout(3000);
    
    	m_networkManager->setConfiguration(networkConfiguration);
    
    	connect(m_networkManager, &QNetworkAccessManager::sslErrors,
    			this, [this](QNetworkReply *reply, const QList<QSslError> &errors){
    
    		qDebug() << reply << errors;
    	});
    
    QNetworkReplyHttpImpl(0x19b6e5ff990) ("The host name did not match any of the valid hosts for this certificate")
    

    my certificate is created by openssl:

    openssl genrsa -out privkey.pem 2048 
    openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095 -config openssl.cnf
    

    what does 'The host name' and the 'the valid hosts' means? and where can I find it or change it?

    thank you so much!


  • Lifetime Qt Champion

    Hi,

    When you create a certificate you have to give informations like for which host it will be valid. From the looks of it, you did not do that.



  • @SGaist

    thank you.
    I am just confused about which host should match the host of the certificate i created when I use network proxy.
    there is two host, one is proxy server host, and the other is the host I actually need to connect.


  • Lifetime Qt Champion

    Usually the final target. Then it depends on your proxy.



  • @SGaist
    ok, thank you very much


Log in to reply