HTTPS安全访问配置过程
第一个历程: 创建私钥过程
openssl genrsa -idea -out server.key 2048 (1024-2048)
genrsa — 指定创建私钥类型
idea — 需要给私钥设置密码信息
out — 进行标准输出
2048 — 密钥加密长度
实际操作:
[root@web01 ssh_key]# openssl genrsa -idea -out server.key 2048
Generating RSA private key, 2048 bit long modulus
........+++
.......+++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
openssl genrsa -out server.key 2048 --- 私钥没有密码信息
第二个历程: 利用私钥创建证书过程
申请真正证书:
云主机 --- 域名信息(备案) --- 证书(域名)
自己创建假证:
openssl req -days 36500 -x509 -sha256 -nodes -newkey rsa:2048 -keyout server.key -out server.crt
req --- 创建证书
days --- 指定证书有效期
x509 --- 证书的格式信息
-nodes -newkey --- 去掉私钥文件密码信息
-keyout --- 加载私钥文件
-out --- 输出生成证书文件(假的)
第三个历程: 利用网站服务加载证书
# 加载ssl crt证书文件存放路径
Syntax: ssl_certificate file; ---- 加载证书信息
Default: —
Context: http, server
# 加载ssl key私钥文件存放路径
Syntax: ssl_certificate_key file; ---- 加载私钥信息
Default: —
Context: http, server
[root@web01 conf.d]# cat www.conf
server {
listen 443 ssl;
server_name www.oldboy.com;
ssl_certificate /etc/nginx/ssh_key/server.crt;
ssl_certificate_key /etc/nginx/ssh_key/server.key;
location / {
root /html/www;
index index.php oldboy.jpg index.html index.htm;
}