<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QNetworkAccessManager SSL双向验证]]></title><description><![CDATA[<p dir="auto">QNetworkAccessManager 如何使用Windows本地证书进行https双向验证？</p>
<p dir="auto">@<br />
QUrl url("<a href="https://www.example.com/../customerLogonAction.biz" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.example.com/../customerLogonAction.biz</a>");<br />
QNetworkRequest request (url);</p>
<p dir="auto">#ifdef WIN32<br />
HCERTSTORE m_hMyStore  = CertOpenSystemStore(0,TEXT("MY"));<br />
if( m_hMyStore)<br />
{<br />
CertControlStore(m_hMyStore, 0, CERT_STORE_CTRL_RESYNC, NULL);<br />
PCCERT_CONTEXT pCertContext = CertFindCertificateInStore(m_hMyStore,<br />
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,<br />
0, CERT_FIND_SUBJECT_STR_A,<br />
"11001065125.0000.0004", NULL );<br />
if( pCertContext )<br />
{<br />
QByteArray byteArray;<br />
byteArray.resize(pCertContext-&gt;cbCertEncoded);<br />
memcpy(byteArray.data(), pCertContext-&gt;pbCertEncoded,<br />
pCertContext-&gt;cbCertEncoded);</p>
<pre><code>        QSslCertificate  cert(byteArray,QSsl::Der);
        QSslConfiguration sslConfiguration;
        sslConfiguration.setLocalCertificate(cert);
        request.setSslConfiguration(sslConfiguration);
    }
}
</code></pre>
<p dir="auto">#endif  // WIN32</p>
<pre><code>QNetworkAccessManager *networkManager= new QNetworkAccessManager(this);
connect(networkManager,SIGNAL(finished(QNetworkReply*)),
                        SLOT(read(QNetworkReply*)));
networkManager-&gt;get(request);
</code></pre>
<p dir="auto">@</p>
<p dir="auto">运行以上代码发生错误，貌似缺少私钥，该如何处理？<br />
@<br />
QNetworkReply::UnknownNetworkError</p>
<p dir="auto">// errorString: Cannot provide a certificate with no key.<br />
@</p>
]]></description><link>https://forum.qt.io/topic/21797/qnetworkaccessmanager-ssl双向验证</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 13:03:50 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/21797.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Nov 2012 08:39:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QNetworkAccessManager SSL双向验证 on Mon, 09 Sep 2013 05:18:56 GMT]]></title><description><![CDATA[<p dir="auto">使用WinHttp或NSS</p>
<p dir="auto">Network Security Services (NSS) is a set of libraries designed to support cross-platform development of security-enabled client and server applications. Applications built with NSS can support SSL v2 and v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME, X.509 v3 certificates, and other security standards.</p>
<p dir="auto">[quote author="sinotitan" date="1378697173"]客户端证书都保存在USBKey中，私钥是读不出来的，如何处理？[/quote]</p>
]]></description><link>https://forum.qt.io/post/175684</link><guid isPermaLink="true">https://forum.qt.io/post/175684</guid><dc:creator><![CDATA[TDHound]]></dc:creator><pubDate>Mon, 09 Sep 2013 05:18:56 GMT</pubDate></item><item><title><![CDATA[Reply to QNetworkAccessManager SSL双向验证 on Mon, 09 Sep 2013 03:26:13 GMT]]></title><description><![CDATA[<p dir="auto">客户端证书都保存在USBKey中，私钥是读不出来的，如何处理？</p>
]]></description><link>https://forum.qt.io/post/175683</link><guid isPermaLink="true">https://forum.qt.io/post/175683</guid><dc:creator><![CDATA[sinotitan]]></dc:creator><pubDate>Mon, 09 Sep 2013 03:26:13 GMT</pubDate></item><item><title><![CDATA[Reply to QNetworkAccessManager SSL双向验证 on Mon, 09 Sep 2013 03:21:11 GMT]]></title><description><![CDATA[<p dir="auto">那么该如何解决？修改openssl还是qt源码？</p>
]]></description><link>https://forum.qt.io/post/175682</link><guid isPermaLink="true">https://forum.qt.io/post/175682</guid><dc:creator><![CDATA[sinotitan]]></dc:creator><pubDate>Mon, 09 Sep 2013 03:21:11 GMT</pubDate></item><item><title><![CDATA[Reply to QNetworkAccessManager SSL双向验证 on Mon, 17 Jun 2013 09:21:51 GMT]]></title><description><![CDATA[<p dir="auto">因为Qt主要基于OpenSSL实现SSL通信，必须显示提供私钥文件。</p>
]]></description><link>https://forum.qt.io/post/175278</link><guid isPermaLink="true">https://forum.qt.io/post/175278</guid><dc:creator><![CDATA[TDHound]]></dc:creator><pubDate>Mon, 17 Jun 2013 09:21:51 GMT</pubDate></item></channel></rss>