ssl创建自签名的https通信

ssl协议:
ssl在tcp之上,http之下。兼容底层协议。所以推广起来很容易。

create a self-signed server certificate -- for test purposes:
生成自签名的CA:

<pre lang="c" escaped="true" line="1">
#openssl req -new -x509 -days 30 -keyout server.key -out server.crt -subj '/CN=Test-Only Certificate'
</pre>
这条命令生成的时候它会提示将私钥加一层口令保护。这个对安全性的还是很重要的。这层口令是对称加密的。
<ul>
<li>-x509是一种标准,现在几乎都用这个标准</li>
<li>days 是有效期 </li>
<li>server.key:私钥文件:</li>
<li>server.crt:证书文件</li>
<li>subj:DN信息.规定这个证书是谁的。</li>
</ul>

<pre lang="c" escaped="true" line="1">
openssl req -new -x509 -days 365 -sha1 -nodes -newkey rsa:1024 -keyout server.key -out server.crt -sbuj '/O=seccure/OU=Seccure Labs/CN=www.emacsvi.com'
</pre>
<ul>
<li>-sha1 指定它的哈希函数</li>
<li>-nodes 不用将密钥进行加密</li>
</ul>
copy the .key and .crt file to the proper directory.

 

posted on 2015-11-21 16:53  liweilijie  阅读(152)  评论(0编辑  收藏  举报

导航