售前咨询
技术支持
渠道合作

详解SSL安装,快速部署HTTPS安全协议

SSL证书安装

在收到CA的证书后,可以将证书部署上服务器,一般APACHE文件直接将KEY+CER复制到文件上,然后修改HTTPD.CONF文件;TOMCAT等,需要将CA签发的证书CER文件导入JKS文件后,复制上服务器,然后修改SERVER.XML;IIS需要处理挂起的请求,将CER文件导入。下面一起了解SSL证书的安装方式:

linux安装SSL证书

1.查看并安装SSL (安装包的名字是mod_ssl)

[root@localhost ~]# rpm -qi motd_ssl

package motd_ssl is not installed

[root@localhost yum.repos.d]# yum install mod_ssl

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

Setting up Install Process

Resolving Dependencies

–> Running transaction check

—> Package mod_ssl.i386 1:2.2.3-31.el5 set to be updated

–> Finished Dependency Resolution

Dependencies Resolved

=============================================================

Package Arch Version Repository Size

===========================================================

Installing:

mod_ssl i386 1:2.2.3-31.el5 file 88 k

Transaction Summary

================================================

Install 1 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 88 k

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

Installing : mod_ssl 1/1

Installed:

mod_ssl.i386 1:2.2.3-31.el5

Complete!

2.手动创建密钥和证书

[root@localhost yum.repos.d]# cd /etc/pki/tls/certs/

[root@localhost certs]# pwd

/etc/pki/tls/certs

[root@localhost certs]# make auth.key (创建一个名为auth的SSL私钥)

umask 77 ;

/usr/bin/openssl genrsa -des3 1024 > auth.key

Generating RSA private key, 1024 bit long modulus

……………………………….++++++

……………………….++++++

e is 65537 (0x10001)

Enter pass phrase:

Verifying – Enter pass phrase:

[root@localhost certs]# make auth.crt (创建一个名为auth的证书)

umask 77 ;

/usr/bin/openssl req -new -key auth.key -x509 -days 365 -out auth.crt -set_serial 0

Enter pass phrase for auth.key: (输入刚才的私钥密码)

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter ., the field will be left blank.

—–

Country Name (2 letter code) [GB]:CN (国家)

State or Province Name (full name) [Berkshire]:liaoning (地区)

Locality Name (eg, city) [Newbury]:dalian (城市)

Organization Name (eg, company) [My Company Ltd]:IBM (组织机构名)

Organizational Unit Name (eg, section) []:IBM (全名)

Common Name (eg, your name or your servers hostname) []:WWW.IBM.COM (公共名称)

Email Address []: (邮箱)

3.修改配置文件 www.linuxidc.com

[root@localhost certs]# cp auth.key /etc/pki/tls/private/ (私钥导入)

[root@localhost certs]# vi /etc/httpd/conf.d/ssl.conf

修改112、 119行:

SSLCertificateFile /etc/pki/tls/certs/localhost.crt

====》SSLCertificateFile /etc/pki/tls/certs/auth.crt

SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

====》SSLCertificateKeyFile /etc/pki/tls/private/auth.key

4.重启apache服务

[root@localhost certs]# service httpd restart

停止httpd: [失败]

启动httpd:Apache/2.2.3 mod_ssl/2.2.3 (Pass Phrase Dialog)

Some of your private key files are encrypted for security reasons.

In order to read them you have to provide the pass phrases.

Server localhost.localdomain:443 (RSA)

Enter pass phrase: (输入私钥密码)

OK: Pass Phrase Dialog successful.

[确定]

[root@localhost certs]# netstat -tunal |grep 443

tcp 0 0 :::443 :::* LISTEN

(监听外部所有端口 到本机的443端口正常 说明启动成功)

4.访问并测试网页 (https:// 172.18.4.88)

1.增加安全例外,查看证书 (我们发现证书颁发机构已经变成了IBM)

2.打开测试页,默认网页正常显示

nginx安装SSL证书

1.安装带有ssl模块的 nginx

[html] view plain copy

wget http://nginx.org/download/nginx-0.8.52.tar.gz

tar zxvf nginx-0.8.52.tar.gz

chown root:root nginx-0.8.52 -R

apt-get install libpcre3 libpcre3-dev

apt-get install openssl

apt-get install libssl-dev

./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module  –with-http_realip_module

make

make install

2.配置nginx 配置文件

[html] view plain copy

ssl on;

ssl_certificate /etc/nginx/nginx_pas/*.crt;

ssl_certificate_key /etc/nginx/nginx_pas/*.key;

  1. 配置nginx的conf ,所有都要求访问https

[html] view plain copy

location / {

rewrite ^/(.*) https://*.com/$1 permanent ;

#root   /var/www/nginx-default;

#index  index.html index.htm;

}

apache 安装SSL证书

1、生成证书请求文件(CSR)。在购买并安装SSL证书之前,你必须在服务器上制作一个CSR文件。该文件中的公钥会用来生成私钥。在Apache中输入如下命令就能直接生成CSR:

打开OpenSSL工具,路径一般为/usr/local/ssl/bin/。

输入如下命令生成密钥:

” openssl genrsa –des3 –out www.mydomain.com.key 2048″

设置密码。以后每次用到密钥时都会要求你输入密码。

开始生成CSR。当收到提示开始创建CSR时,请输入如下命令:

“openssl req –new –key www.mydomain.com.key –out www.mydomain.com.csr”

填好相关信息。这些信息包括:两位数的国家代码、州名或省份名、城镇名、企业全名、部门名称(如:IT部或市场部)及通用名(也就是域名)。

生成CSR文件。填好信息后,输入以下命令就能在服务器上生成CSR文件了:[1]

“openssl req -noout -text -in www.mydomain.com.csr”

2、申请SSL证书。提供在线SSL证书申请服务的网站有很多,一定要选择有名气的网站申请,因为这关系到你和你用户的安全。比较受欢迎的网站包括DigiCert、Symantec、GlobalSign等等。要根据自己的需求(如多个证书的申请、企业服务解决方案等)来选择最适合自己的网站。

在相关网站上申请时,需要提交CSR文件。这样你的服务器上就能生成证书了。

3、下载证书。在你购买证书的网站上,你需要下载一份中级证书。接着,你就会通过邮件或在网站客户区收到一份初级证书,其中的密钥应如下所示:

“—–BEGIN CERTIFICATE—–

[Encoded Certificate]

—–END CERTIFICATE—–”

如果证书是文本形式的,那么在上传之前,你要先将其转换为CRT文件。

检查下载的密钥。密钥中BEGIN CERTIFICATE及ENG CERTIFICATE的两边应该各有5个“-”。同时要确保密钥中没有多余的空格或空行。

4、将证书上传到服务器。证书要放在专门用于存放证书及密钥文件的文件夹里。例如,你可以将所有相关文件都存放在如下路径下:/usr/local/ssl/crt/。

5、在文本编辑器中打开“http.conf”文件。 有些版本的Apache包含一个叫做“ssl.conf”的配置文件。两个文件只能修改其一。在Virtual Host部分添加如下代码:[2]

“SSLCertificateFile /usr/local/ssl/crt/primary.crt

SSLCertificateKeyFile /usr/local/ssl/private/private.key

SSLCertificateChainFile /usr/local/ssl/crt/intermediate.crt”

完成后,保存对文件的修改。必要情况下重新上传。

6、重启服务器。文件修改后,只要重启一下服务器就可以开始使用SSL证书了。大多数版本都可以通过如下命令来重启:

“apachectlp stop

apachectl startssl”

  • 测试证书。用各种浏览器来测试一下SSL证书是否有效。

wdcp安装SSL证书

  1. 登录WDCP 后台 ,  打开 “系统管理” , “文件管理”
  1.  前端使用 “nginx”  , 就选择nginx。 新建站点后,这里都会生成一个用域名命名的配置文件。

将配置文件复制一份,保存为 “ssl.conf” 。 名字可以自己定义。

wdcp_1.png

  1. 修改ssl.conf配置文件 (修改端口和添加SSL配置,红色标记部分, 证书自己上传到 /www/ssl 目录。)

apache方式也一样,请参考Apache配置教程。

server { listen 443;server_name www.domain.com;

root /www/web/domain/public_html;

index index.html index.php index.htm;ssl on; ssl_certificate /www/ssl/server.crt; ssl_certificate_key /www/ssl/server.key; ssl_protocols TLSv1.2 TLSv1.1 TLSv1; ssl_prefer_server_ciphers on;error_page 400 /errpage/400.html;

error_page 403 /errpage/403.html;

error_page 404 /errpage/404.html;

location ~ .php$ {

proxy_pass http://127.0.0.1:88;

include naproxy.conf;

}

location / {

try_files $uri @apache;

}

location @apache {

proxy_pass http://127.0.0.1:88;

include naproxy.conf;

}

}

  1.  重启web服务  (系统管理 —>  服务重启)
  1.   安全管理 –> 防火墙(iptables) .

上一篇:

下一篇:

相关文章