﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>学习日记 &#187; https</title>
	<atom:link href="https://www.softwareace.cn/?feed=rss2&#038;tag=https" rel="self" type="application/rss+xml" />
	<link>https://www.softwareace.cn</link>
	<description>时刻想着为自己的产品多做一些对他好的事情</description>
	<lastBuildDate>Fri, 20 Mar 2026 06:58:28 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>Qt 访问 https</title>
		<link>https://www.softwareace.cn/?p=202</link>
		<comments>https://www.softwareace.cn/?p=202#comments</comments>
		<pubDate>Tue, 26 Feb 2013 03:29:51 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[Qt Gui]]></category>
		<category><![CDATA[https]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=202</guid>
		<description><![CDATA[Qt 是支持 SSL的，但是由于某些法律和政策因素，QT的开发包里并没有集成openSSL。QT采用两种方式调 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Qt 是支持 SSL的，但是由于某些法律和政策因素，QT的开发包里并没有集成openSSL。QT采用两种方式调用openSSL，默认方式是动态加载openSSL的 DLL。 在Windows系统上默认没有openSSL，需要自己安装。 可以在这里下载源代码，自己编译</p>
<p>http://www.openssl.org/source/</p>
<p>也可以在这里下载编译好的版本，直接安装 http://www.slproweb.com/products/Win32OpenSSL.html<br />
如果要静态链接ssl，那就要自己重新编译QT才行，首先设置环境变量 OPENSSL_LIBS，指向你的openSSL的lib目录，然后执行configure的时候使用以下参数 configure -openssl-linked<br />
使用方法和简单和普通的 http请求没什么不同。</p>
<div><!--
Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/
--> QUrl url(http://code.google.com&#8221;); QHttp *http = new QHttp(); http-&gt;setHost(url.host(), QHttp::ConnectionModeHttps, url.port()); QFile *file = new QFile(&#8220;index.htm&#8221;); file-&gt;open(QIODevice::WriteOnly) int httpGetId = http-&gt;get(path, file);</div>
<p>由于QHttp是异步调用，你需要连接几个signal来获取下载进度。<br />
在S60平台，以上代码也是可以运行的，需要注意的是在 Qt 4.6 beta版本里我怀疑有个bug，qt会在s60上试图去加载 ssleay32.dll，但是在s60上openSSL的DLL名字是 libssl.dll。这个问题已经在最新的 QT 4.6 正式版本里修复了，请更新到最新的QT. 另外，如果以上代码在 S60上运行，这个 index.htm文件会被创建在程序的私有目录里，这个目录是文件管理器看不到的，所以要改成 类似 c:\index.htm的名字，好用来验证下载是否正确。<br />
现在的 QT 其实并不推荐继续使用 QHttp了，应该用 QNetworkAccessManager，这是一个更先进的网络连接服务，其行为和你的浏览器基本一致，包括了代理和缓冲的支持，所以这也是QT webkit使用的连接方式。</p>
<p>在windows下面我用Qt 访问https的服务器的时候开始也不行，后面我下载了一个Win32OpenSSL_Light-1_0_1c将libeay32.dll和ssleay32.dll放到Qt的bin目录下面去就支持了</p>
<p>测试例子examplesnetworkhttp</p>
<p><a href="http://stackoverflow.com/questions/5630512/support-for-https-using-qnetworkaccessmanager-hitting-sslerrors-at-runtime">http://stackoverflow.com/questions/5630512/support-for-https-using-qnetworkaccessmanager-hitting-sslerrors-at-runtime</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=202</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
