纲手大神官 發表於 2017-2-8 16:23:20

CentOS7自生成证书配置SSL WEB详解

<div class="jb51code">
<pre class="brush:bash;"># 安装Apache # yum -y install httpd mod_ssl
# 添加防火墙规则 # firewall-cmd --permanent --add-server=80/tcp
# firewall-cmd --permanent --add-server=443/tcp
# firewall-cmd --permanent --add-server=8080/tcp;firewall-cmd --reload # systemctl restart httpd;systemctl enable httpd</pre>
</div>
<div class="jb51code">
<pre class="brush:bash;"># 配置selinux安全上下文
# semanaga port -a -t http_port_t {80,443,8080} # mkdir /etc/httpd/ssl;cd /etc/httpd/ssl </pre>
</div>
<p># 生成KEY </p>
<p># openssl genrsa -des3 -out vqiu.cn.key 2048 </p>
<p># 去密码 </p>
<p># openssl rsa -in vqiu.cn.key -out vqiu.cn.key# 生成证书签发请求和证书密钥 </p>
<p># openssl req -new -nodes -key vqiu.cn.key -out vqiu.cn.csr </p>
<p># 通过csr生成一个证书,以 vqiu.cn 为例 </p>
<p># openssl x509 -req -days 3650 -in vqiu.cn.csr -signkey vqiu.cn.key -out vqiu.cn.crt </p>
<p>#生成 crt 之后,csr 可以进行删除[可略过] </p>
<p># rm vqiu.cn.csr -f </p>
<p># cat /etc/httpd/conf.d/vqiu.cn.conf </p>
<p>&lt;IfModule mod_ssl.c&gt; </p>
<p>Listen 443 https </p>
<p>&lt;/IfModule&gt; </p>
<p>&lt;VirtualHost _default_:443&gt; </p>
<p>ServerName server0.vqiu.cn </p>
<p>DocumentRoot /var/www/html </p>
<p>SSLEngine on </p>
<p>SSLProtocol all -SSLv2 </p>
<p>SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5 </p>
<p>SSLCertificateFile /etc/httpd/ssl/vqiu.cn.crt </p>
<p>SSLCertificateKeyFile /etc/httpd/ssl/vqiu.cn.key </p>
<p>&lt;/VirtualHost&gt; </p>
<p># 生成一个测试页面 </p>
<p># echo &quot;test&quot;&gt;/var/www/html/index.html </p>
<p># 重启httpd服务 </p>
<p># systemctl restart httpd </p>
頁: [1]
查看完整版本: CentOS7自生成证书配置SSL WEB详解