LinuxSSL证书安装过程

SSL 证书安装过程第一步:安装mod_ssl[root@300second ~]# yum -y install mod_ssl第二步:HTTP 服务器上配置mod_ssl[1] 建立服务器密钥[r

SSL 证书安装过程

第一步:安装mod_ssl

[root@300second ~]# yum -y install mod_ssl

第二步:HTTP 服务器上配置mod_ssl

[1] 建立服务器密钥

[root@300second ~]# cd /etc/pki/tls/certs/ ← 进入HTTP 服务器配置文件所在目录

[root@300second certs]# make server.key ← 建立服务器密钥 umask 77 ;

/usr/bin/openssl genrsa -des3 1024 > server.key Generating RSA private key, 1024 bit long modulus ................ ...... e is 65537 (0x10001)

Enter pass phrase: ← 在这里输入口令

Verifying - Enter pass phrase: ← 确认口令,再次输入

[root@300second certs]# openssl rsa -in server.key -out server.key ← 从密钥中删除密码(以避免系统启动后被询问口令)

Enter pass phrase for server.key: ← 输入口令

writing RSA key

[2] 建立服务器公钥

[root@300second certs]# make server.csr ← 建立服务器密钥 umask 77 ;

/usr/bin/openssl req -utf8 -new -key server.key -out server.csr 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]:Fujian ← 输入省名 Locality Name (eg, city) [Newbury]:Quanzhou ← 输入城市名

Organization Name (eg, company) [My Company Ltd]:www.51cto.com ← 输入组织名(任意)

,

Organizational Unit Name (eg, section) []: ← 不输入,直接回车

Common Name (eg, your name or your server's hostname) []:www.51cto.com ← 输入通称(任意)

Email Address []:300second@163.com ← 输入电子邮箱地址 Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []: ← 不输入,直接回车

An optional company name []: ← 不输入,直接回车

[3] 建立服务器证书

[root@300second certs]# openssl x509 -in server.csr -out server.pem -req -signkey server.key -days 365 ← 建立服务器证书 Signature ok subject=/C=CN/ST=Fujian/L=Quanzhou/O=www.51cto.com/CN=www.51cto.com/emailAddress=300second@163.com

Getting Private key

[root@300second certs]# chmod 400 server.* ← 修改权限为400

[4] 设置SSL

[root@300second certs]# vi /etc/httpd/conf.d/ssl.conf ← 修改SSL 的设置文件

#DocumentRoot "/var/www/html" ← 找到这一行,将行首的“#”去掉

DocumentRoot "/var/www/html" ← 变为此状态

[5] 重新启动HTTP 服务,让SSL 生效

[root@300second certs]# /etc/rc.d/init.d/httpd restart ← 重新启动HTTP 服务器

停止 httpd: [ 确定 ]

启动 httpd: [ 确定]

第三步:到StartSSL 申请免费证书: StartSSL 免费SSL 证书成功申请-HTTPS 让访问网站更安全

一、StartSSL 个人证书登录申请

1、StartSSL 官网:

,

2、第一次用StartSSL ,先进入控制面板,先点击注册。

3、然后是填写你的个人基本信息,以部落的经验,主要地址填写详细,StartSSL 会根据你的IP 自动填入你所在的地址。

4、提交后你的邮箱会收到一个验证码。

,

5、用这个验证码输入填写验证。

6、验证成功后,要么是等待人工审核开通,要么是直接提示下载个人操作证书。

二、通过StartSSL 审核下载安装个人操作证书

1、一般情况下几分钟后就可以收到StartSSL 审核通过的邮件了,没有通过的话会问你一些问题,随便回复一下就OK 了。像部落是直接开通,提示让我下载证书。

,

2、点击安装,稍等几分钟就会自动在浏览器上安装StartSSL 操作证书了。

3、部落用了是Chrome 浏览器,提示安装成功。

4、安装好了个人操作证书后,就可以返回到控制面板,点击Authenticate 凭证书登录了。

三、StartSSL 免费SSL 通过域名验证

,

1、上面是获得了StartSSL 的个人操作登录使用权,接下来我们要用自己的域名来申请一个StartSSL 免费SSL 证书了。

2、点击Validations Wizard,选择Domain name validation,点击Continue 。

3、输入你想要使用SSL 的域名,点击继续。

4、接下来选择你的域名所有者的邮箱,如果你的域名设置了Whois 保护,可能还要先进入域名注册商那里取消保护,否则无法使用域名管理员邮箱通过域名所有权验证。

,

5、提交了域名后,到邮箱中收取激活邮件,填入验证码,通过验证。

四、申请StartSSL 生成域名的SSL 证书

1、上面已经提交了域名并通过了所有权验证,点击Certificates Wizard,选择WEB Server SSL/TSL Certifites 。

2、生成私钥,为私钥提供一个密码,最少10位,最大32位。

,

3、将显示内容保存为freehao123.key (这个私钥是加密的),继续点击下一步。

4、输入你要绑定的二级域名,一般是www 。

5、提交后还得再等待StartSSL 审核,一般是几分钟后就可以收到邮件通知。当然也有审核不通过的,例如部落的因为域名的关系,直接被拒绝了,只好换一个域名了。The domain s0su.com could be easily

,

mistaken with the domain sosu.com in which case our policy doesn’t allow it to be issued. Sorry for the inconvenience!

第四步:以下是在Linux 上配置过程: 1、修改httpd.conf 文件

**RPM安装的情况下,不需要修改httpd.conf 文件,因为在httpd.conf 文件中默认添加了 include conf.d/*.conf。而在rpm 安装时,conf.d 文件夹中已含有ssl.conf 文件。所以只要修改ssl.conf 文件就可以了。**

**RPM安装的Apahce 时,可能一开始没有mod-ssl ,需要安装。方法为:yum install mod_ssl 或者用rpm 包安装,需要mod_ssl arp_util distcache httpd postgresql-libs等伊来关系。**

需要修改时可在httpd.conf 文件中加上include conf.d/ssl.conf(用于ssl 模块使用的conf 文件的路径即可) 。

2、修改ssl.conf 文件

[root@localhost conf.d]#cp -p ssl.conf ssl.conf.bk

[root@localhost conf.d]#vi ssl.conf

---------------------------------------

Listen 443 //可以改成其他端口

SSLPassPhraseDialog builtin //每次重启Apache 时需要输入密码

SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)

SSLSessionCacheTimeout 300

SSLMutex default

SSLRandomSeed startup builtin

SSLRandomSeed connect builtin

SSLEngine on

SSLCertificateFile /etc/httpd/conf/ssl.crt/server.crt(在startssl 申请的crt ,将文件copy 到对应的文件夹下)

SSLCertificateKeyFile /etc/httpd/conf/ssl.crt/server.key(在startssl 申请的key 将文件copy 到对应的文件夹下)

SSLCACertificateFile /etc/httpd/conf/ssl.crt/ca.crt //双向时使用

SSLVerifyClient require //双向时使用, 强制客户必须持有SSL 证书请求

SSLVerifyDepth 10 //双向时使用

,

3、重启Apache

[root@localhost ssl.crt]#service httpd restart

此时可能需要密码:此时密码就是你在申请证书时,生成私钥时输入的密码。

4、开启防火墙端口

标签: