<?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; 证书生成</title>
	<atom:link href="http://blog.myhnet.cn/tag/%e8%af%81%e4%b9%a6%e7%94%9f%e6%88%90/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.myhnet.cn</link>
	<description>秋湍泻石髓 风叶聚云根</description>
	<lastBuildDate>Fri, 20 Aug 2010 15:05:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>如何为自己的网站生成SSL证书</title>
		<link>http://blog.myhnet.cn/2009/01/13/how-to-create-ssl-certificate-for-your-own-website/</link>
		<comments>http://blog.myhnet.cn/2009/01/13/how-to-create-ssl-certificate-for-your-own-website/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 04:45:37 +0000</pubDate>
		<dc:creator>myhnet</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[证书]]></category>
		<category><![CDATA[证书生成]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[ssl证书]]></category>

		<guid isPermaLink="false">http://blog.myhnet.cn/?p=529</guid>
		<description><![CDATA[1. 首先保证安装了Openssl，并且能够在在终端执行它。 2. 为你的Apache（三倍-DES加密，PEM格式） 创建一个RSA私钥。 $&#160; &#160;openssl&#160; &#160;genrsa&#160; &#160;-des3&#160; &#160;-out&#160; &#160;server.key&#160; &#160;1024 请将你的server.key文件备份，并且记住你输入得进入密码。能够通过以下的命令察看该文件： $&#160; &#160;openssl&#160; &#160;rsa&#160; &#160;-noout&#160; &#160;-text&#160; &#160;-in&#160; &#160;server.key 你也可以通过以下的命令创建一个没有加密的版本（不建议）： $&#160; &#160;openssl&#160; &#160;rsa&#160; &#160;-in&#160; &#160;server.key&#160; &#160;-out&#160; &#160;server.key.unsecure 3. 通过RSA私钥文件来创建一个证书请求文件（PEM格式，CSR） $&#160; &#160;openssl&#160; &#160;req&#160; &#160;-new&#160; &#160;-key&#160; &#160;server.key&#160; &#160;-out&#160; &#160;server.csr 同样，你需要做一个备份，同时，在Openssl命令行提示输入CommonName的过程中，你必须输入一个FQDN（一个完全的有资格的域名），一个站点生成了一个CSR请求文件。可以通过以下的命令来查看CSR的详细内容： $&#160; &#160;openssl&#160; &#160;req&#160; &#160;-noout&#160; &#160;-text&#160; &#160;-in&#160; &#160;server.csr 4. 现在，你已经有了一个证书请求文件（CSR）了，你可以将此文件发送给一个认证机构来进行认证，当然会等一段时间并且花上一些钱。或者通过自己的CA认证机构来进行认证。 § Verisign http://digitalid.verisign.com/server/apacheNotice.htm § Thawte Consulting http://www.thawte.com/certs/server/request.html [...]]]></description>
			<content:encoded><![CDATA[<p>  1. 首先保证安装了Openssl，并且能够在在终端执行它。<br />
  2. 为你的Apache（三倍-DES加密，PEM格式）   创建一个RSA私钥。  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;genrsa&nbsp; &nbsp;-des3&nbsp; &nbsp;-out&nbsp; &nbsp;server.key&nbsp; &nbsp;1024</div></div>
<p>  请将你的server.key文件备份，并且记住你输入得进入密码。能够通过以下的命令察看该文件：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;server.key</div></div>
<p>  你也可以通过以下的命令创建一个没有加密的版本（不建议）：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-in&nbsp; &nbsp;server.key&nbsp; &nbsp;-out&nbsp; &nbsp;server.key.unsecure</div></div>
<p>  3. 通过RSA私钥文件来创建一个证书请求文件（PEM格式，CSR）  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;req&nbsp; &nbsp;-new&nbsp; &nbsp;-key&nbsp; &nbsp;server.key&nbsp; &nbsp;-out&nbsp; &nbsp;server.csr</div></div>
<p>  同样，你需要做一个备份，同时，在Openssl命令行提示输入CommonName的过程中，你必须输入一个FQDN（一个完全的有资格的域名），一个站点生成了一个CSR请求文件。可以通过以下的命令来查看CSR的详细内容：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;req&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;server.csr</div></div>
<p>  4. 现在，你已经有了一个证书请求文件（CSR）了，你可以将此文件发送给一个认证机构来进行认证，当然会等一段时间并且花上一些钱。或者通过自己的CA认证机构来进行认证。<br />
  § Verisign<br />
  <a href="http://digitalid.verisign.com/server/apacheNotice.htm">http://digitalid.verisign.com/server/apacheNotice.htm  </a><br />
  § Thawte   Consulting<br />
  <a href="http://www.thawte.com/certs/server/request.html ">http://www.thawte.com/certs/server/request.html </a><br />
  § CertiSign   Certificadora   Digital   Ltda.<br />
  <a href="http://www.certisign.com.br">http://www.certisign.com.br  </a><br />
  § IKS   GmbH<br />
 <a href=" http://www.iks-jena.de/produkte/ca/"> http://www.iks-jena.de/produkte/ca/</a><br />
  § Uptime   Commerce   Ltd.<br />
  <a href="http://www.uptimecommerce.com ">http://www.uptimecommerce.com </a><br />
  § BelSign   NV/SA<br />
 <a href=" http://www.belsign.be"> http://www.belsign.be</a><br />
  通过以下的命令来察看经过认证的证书信息。  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;x509&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;server.crt</div></div>
<p>  5. 现在，我们有了两个文件，server.key和server.crt   ，下面就是在Apache中的httpd.conf文件配置：  </p>
<div class="hl-surround"><div class="hl-main">SSLCertificateFile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/path/to/this/server.crt&nbsp; <br />&nbsp; SSLCertificateKeyFile&nbsp; &nbsp;/path/to/this/server.key</div></div>
<p>  请求文件不再需要了。<br />
  · 使用自认证机构：<br />
  最简单的就是通过CA.pl或者是通过CA.sh来对请求文件签名。<br />
  1. 为你的CA创建一个RSA私钥（三DES加密并且是PEM格式）：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;genrsa&nbsp; &nbsp;-des3&nbsp; &nbsp;-out&nbsp; &nbsp;ca.key&nbsp; &nbsp;1024</div></div>
<p>  备份并且记住你输入的访问密码。通过以下的命令可以查看私钥的详细信息：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;ca.key</div></div>
<p>  你也可以创建一个非加密的PEM格式的私钥：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-in&nbsp; &nbsp;ca.key&nbsp; &nbsp;-out&nbsp; &nbsp;ca.key.unsecure</div></div>
<p>  2. 创建一个自签名的证书文件（X.509   结构,输出为PEM格式）：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;req&nbsp; &nbsp;-new&nbsp; &nbsp;-x509&nbsp; &nbsp;-days&nbsp; &nbsp;365&nbsp; &nbsp;-key&nbsp; &nbsp;ca.key&nbsp; &nbsp;-out&nbsp; &nbsp;ca.crt</div></div>
<p>  通过以下的命令查询：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;x509&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;ca.crt</div></div>
<p>  3. 准备一个脚本文件来对请求文件签名，Openssl不允许简单的通过openssl   ca来对请求文件签名。所以一个名为sign.sh的脚本文件（mod_ssl的子目录pkg.contrib下），是用这个来进行签名，不过还是建议使用下面的方法进行签名。  </p>
<p>  4. 现在可以用这个脚本来进行签名了（刚才生成的CA的私钥和证书必须在这个脚本的目录下）：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;./sign.sh&nbsp; &nbsp;server.csr</div></div>
<p>  得到一个证书文件—〉server.crt.<br />
  · 怎样更改我的私钥的   pass-phrase   密码？<br />
  只需要简单的读取它并重新写入，同时指定它的pass-phrase   ，通过以下的命令完成：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-des3&nbsp; &nbsp;-in&nbsp; &nbsp;server.key&nbsp; &nbsp;-out&nbsp; &nbsp;server.key.new&nbsp; <br />&nbsp; $&nbsp; &nbsp;mv&nbsp; &nbsp;server.key.new&nbsp; &nbsp;server.key</div></div>
<p>  这时，你被要求两次来输入一个PEM   的pass-phrase，第一次要求输入旧密码，第二次要求输入新密码。<br />
  · 怎样可以消除Apache启动的时候的密码（pass-phrase）提示对话框：<br />
  原因是保存在你的私钥文件中的RSA私钥是一个一加密格式保存的。密码是保证能够读取这个密钥文件，如果保证你的服务器足够的安全的话，可以通过以下的命令消除：<br />
  1. 从RSA私钥中移除密码（同时保留源文件）：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;cp&nbsp; &nbsp;server.key&nbsp; &nbsp;server.key.org&nbsp; <br />&nbsp; $&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-in&nbsp; &nbsp;server.key.org&nbsp; &nbsp;-out&nbsp; &nbsp;server.key</div></div>
<p>  2. 保证私钥只能被root用户读取：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;chmod&nbsp; &nbsp;400&nbsp; &nbsp;server.key</div></div>
<p>  现在这是一个没有没有加密的密钥拷贝。在使用这个密钥文件的时候，将不会再提示你输入密码，然而，如果其他任何人的到这个私钥文件，他都可以在网络上模仿你。所以一定要保证这个密钥文件只能被root用户读取。<br />
  · 怎么验证私钥文件和我的证书文件是匹配的？<br />
  私钥文件包括一系列的数字。这些数字中的两个是“来自“公钥文件的，其他的是私钥的一部分。公钥的一些bit值被嵌入到你的证书中（我们可以从证书CSR中得到），通过以下的命令来查看输出的数字，同时比较这些数字：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;x509&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;server.crt&nbsp; <br />&nbsp; $&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-noout&nbsp; &nbsp;-text&nbsp; &nbsp;-in&nbsp; &nbsp;server.key</div></div>
<p>  他们必须一致，因为它们都是很长的串，所以可以通过下面的方法来查看：  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;x509&nbsp; &nbsp;-noout&nbsp; &nbsp;-modulus&nbsp; &nbsp;-in&nbsp; &nbsp;server.crt&nbsp; &nbsp;|&nbsp; &nbsp;openssl&nbsp; &nbsp;md5&nbsp; <br />&nbsp; $&nbsp; &nbsp;openssl&nbsp; &nbsp;rsa&nbsp; &nbsp;-noout&nbsp; &nbsp;-modulus&nbsp; &nbsp;-in&nbsp; &nbsp;server.key&nbsp; &nbsp;|&nbsp; &nbsp;openssl&nbsp; &nbsp;md5</div></div>
<p>  这时比较两个短的数字串  </p>
<div class="hl-surround"><div class="hl-main">$&nbsp; &nbsp;openssl&nbsp; &nbsp;req&nbsp; &nbsp;-noout&nbsp; &nbsp;-modulus&nbsp; &nbsp;-in&nbsp; &nbsp;server.csr&nbsp; &nbsp;|&nbsp; &nbsp;openssl&nbsp; &nbsp;md5</div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.myhnet.cn/2009/01/13/how-to-create-ssl-certificate-for-your-own-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
