Qt5 QWebView how to send client certificate?
-
I use Qt5's QWebView to load a https website, which need client certificate. I have installed client certificate and used chrome and ie browser to test ok. But it didn't work in the QWebView.
@QNetworkRequest request;
request.setUrl(QUrl("https://mysite.com/default2.aspx"));QSslConfiguration conf = request.sslConfiguration();
//get the client certificate
QByteArray certData = getCertInWindowsMyStore();
QSslCertificate sslCert(certData, QSsl::Der);
conf.setLocalCertificate(sslCert);request.setSslConfiguration(conf);
ui->webView->load(request);@
I print the certicate's subjectinfo which is correctly.
I seach some infomation from google. Someone says I have to set the private key, someone didn't set also can work fine. How it works?
And I think that I used chrome browser to visit that website, it work fine, but chrome wouldn't know the private key, so I think the private key no need to set.Does anyone know how to do? This question has tortured me very much!
-
check the following if the certificate is more or less valid after you have created it.
From the QSslCertificate docs:
[quote]
After loading a certificate, you can find information about the certificate, its subject, and its issuer, by calling one of the many accessor functions, including version(), serialNumber(), issuerInfo() and subjectInfo(). You can call effectiveDate() and expiryDate() to check when the certificate starts being effective and when it expires. The publicKey() function returns the certificate subject's public key as a QSslKey. You can call issuerInfo() or subjectInfo() to get detailed information about the certificate issuer and its subject.[/quote] -
Thanks again!
I have check that but still no clue. :(
Could you know some example?
Does it need set private key?[quote author="raven-worx" date="1388672307"]check the following if the certificate is more or less valid after you have created it.
From the QSslCertificate docs:
[quote]
After loading a certificate, you can find information about the certificate, its subject, and its issuer, by calling one of the many accessor functions, including version(), serialNumber(), issuerInfo() and subjectInfo(). You can call effectiveDate() and expiryDate() to check when the certificate starts being effective and when it expires. The publicKey() function returns the certificate subject's public key as a QSslKey. You can call issuerInfo() or subjectInfo() to get detailed information about the certificate issuer and its subject.[/quote][/quote]