<?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="http://cocobear.info/blog/tag/https/feed/" rel="self" type="application/rss+xml" />
	<link>http://cocobear.info/blog</link>
	<description>K.I.S.S</description>
	<lastBuildDate>Sat, 10 Dec 2011 16:11:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Openssl建立SSL连接分析</title>
		<link>http://cocobear.info/blog/2009/05/22/openssl-connect/</link>
		<comments>http://cocobear.info/blog/2009/05/22/openssl-connect/#comments</comments>
		<pubDate>Fri, 22 May 2009 02:29:15 +0000</pubDate>
		<dc:creator>可可熊</dc:creator>
				<category><![CDATA[安全相关]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[openssl]]></category>

		<guid isPermaLink="false">http://cocobear.info/blog/?p=659</guid>
		<description><![CDATA[SSL_library_init(); SSL的初始化过程，只是添加一些算法，使用EVP_add_cipher函数。 ssl_method = SSLv3_client_method(); 设置使用的SSL版本，SSLv3_client_method 函数的定义是通过IMPLEMENT_ssl3_meth_func(ssl/s3_clnt.c)这个宏来实现，而这个宏在ssl/ssl_locl.h 文件中实现，使用了粘贴宏的技巧来根据传入不同的函数名生成不同的函数定义。 SSLv3_client_method 定义了一组关于SSL V3的操作函数： static SSL_METHOD func_name##_data= { SSL3_VERSION, ssl3_new, ssl3_clear, ssl3_free, s_accept, s_connect, ssl3_read, ssl3_peek, ssl3_write, ssl3_shutdown, ssl3_renegotiate, ssl3_renegotiate_check, ssl3_get_message, ssl3_read_bytes, ssl3_write_bytes, ssl3_dispatch_alert, ssl3_ctrl, ssl3_ctx_ctrl, ssl3_get_cipher_by_char, ssl3_put_cipher_by_char, ssl3_pending, ssl3_num_ciphers, ssl3_get_cipher, s_get_meth, ssl3_default_timeout, &#38;SSLv3_enc_data, ssl_undefined_void_function, ssl3_callback_ctrl, ssl3_ctx_callback_ctrl, }; SSL_CTX = SSL_CTX_new(ssl_method); 创建SSL_CTX这个结构体，进行初始化赋值操作，设置一些参数，使用默认的engine。openssl的engine是对基础的加密算法进行了封装，这样可以方便的对底层的加密算法进行替换，例如你可能使用硬件加密来替换掉openssl的软实现加密算法，而你所做的只是按照engine的接口实现相关的算法，然后设置engine的名字。例如U-KEY的RSA签名必须在硬件中完成，这时你就可以通过engine调用CSP来实现签名算法。 SSL_CTX_use_certificate_file(SSL_CTX,&#8221;client.cer&#8221;,SSL_FILETYPE_PEM) 设置客户端使用的证书，从文件中读取BASE64(SSL_FILETYPE_PEM这个参数指定)编码的证书，然后转换为openssl 的X509结构，提取公钥，设置SSL_CTX相关的结构。 SSL_CTX_use_PrivateKey_file(SSL_CTX, &#8220;client.key&#8221;, SSL_FILETYPE_PEM) [...]]]></description>
		<wfw:commentRss>http://cocobear.info/blog/2009/05/22/openssl-connect/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

