3 自建 HTTPS 证书
来源:互联网 发布:刷话题软件 编辑:程序博客网 时间:2024/05/14 14:05
- CA 证书的分类
- 生成密钥证书
- Nginx 部署证书
CA 证书的分类
需要强调的是,不论是 DV、OV还是 EV 证书,其加密效果都是一样的。它们的区别在于:
- DV(Domain Validation):面向个体用户,安全体系相对较弱,验证方式就是向 whois 信息中的邮箱发送邮件,按照邮件内容进行验证即可通过;
- OV(Organization Validation):面向企业用户,证书在 DV 证书验证的基础上,还需要公司的授权,CA 通过拨打信息库中公司的电话来确认;
- EV(Extended Validation):打开 Github 的网页,你会看到 URL 地址栏展示了注册公司的信息,这会让用户产生更大的信任,这类证书的申请除了以上两个确认外,还需要公司提供金融机构的开户许可证,要求十分严格。
OV 和 EV 证书相当昂贵,使用方可以为这些颁发出来的证书买保险,一旦 CA 提供的证书出现问题,一张证书的赔偿金可以达到 100w 刀以上。
生成密钥、证书
1 为服务器端和客户端准备公钥、私钥。
# 生成服务器端私钥openssl genrsa -out server.key 1024# 生成服务器端公钥openssl rsa -in server.key -pubout -out server.pem# 生成客户端私钥openssl genrsa -out client.key 1024# 生成客户端公钥openssl rsa -in client.key -pubout -out client.pem
2 生成 CA 证书
# 生成 CA 私钥openssl genrsa -out ca.key 1024# X.509 Certificate Signing Request (CSR) Management.openssl req -new -key ca.key -out ca.csr# X.509 Certificate Data Management.openssl x509 -req -in ca.csr -signkey ca.key -out ca.crt
在执行第二步时会出现:
➜ keys openssl req -new -key ca.key -out ca.csrYou are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [AU]:CNState or Province Name (full name) [Some-State]:ZhejiangLocality Name (eg, city) []:HangzhouOrganization Name (eg, company) [Internet Widgits Pty Ltd]:My CAOrganizational Unit Name (eg, section) []:Common Name (e.g. server FQDN or YOUR name) []:localhostEmail Address []:
注意,这里的 Organization Name (eg, company) [Internet Widgits Pty Ltd]: 后面生成客户端和服务器端证书的时候也需要填写,不要写成一样的!!!可以随意写如:My CA, My Server, My Client。
然后 Common Name (e.g. server FQDN or YOUR name) []: 这一项,是最后可以访问的域名,我这里为了方便测试,写成 localhost,如果是为了给我的网站生成证书,需要写成 barretlee.com。
3 生成服务器端证书和客户端证书
# 服务器端需要向 CA 机构申请签名证书,在申请签名证书之前依然是创建自己的 CSR 文件openssl req -new -key server.key -out server.csr# 向自己的 CA 机构申请证书,签名过程需要 CA 的证书和私钥参与,最终颁发一个带有 CA 签名的证书openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in server.csr -out server.crt# client 端openssl req -new -key client.key -out client.csr# client 端到 CA 签名openssl x509 -req -CA ca.crt -CAkey ca.key -CAcreateserial -in client.csr -out client.c
Nginx 部署证书
server { listen 443 ssl; server_name www.domain.com ssl on; ssl_certificate /etc/nginx/ssl/ssl.crt; ssl_certificate_key /etc/nginx/ssl/ssl.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location /workbench { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 90; } location /main { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 90; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS'; add_header Access-Control-Allow-Credentials 'true'; add_header Access-Control-Allow-Headers 'content-type, authorization, if-none-match, x-requested-with, Content-Range, Content-Length'; } location / { }}
阅读全文
0 0
- 3 自建 HTTPS 证书
- iOS HTTPS 自建证书
- HTTPS 自建证书请求
- HTTPS自建证书
- https自建证书访问
- 自建证书配置HTTPS服务器
- https SSL 自建证书的制作
- https——自建证书验证
- linux中自建证书搭建https
- 使用PHP SoapClient 处理自建证书的https服务
- 43.https自建证书在 AFN中的设置
- ios https访问自建证书时遇到的问题
- 自建https证书,并使用nginx做代理,部署网站
- iOS开发中AFNetworking中如何设置https请求(使用自建证书)
- iOS 迁移到HTTPS(自建证书+单向验证+AF3.0+WKWebView+SDWebImage)
- iOS 迁移到HTTPS(自建证书+单向验证+AF3.0+WKWebView+SDWebImage)
- 自建CA 颁发证书
- 自建https服务器
- PHPExcel插件工具
- 监听器--监听session创建后计数(servletContext)
- 简单工厂、工厂方法、抽象工厂、策略模式、策略与工厂的区别
- malloc(0)
- Android 7.0 调用系统相机拍照、裁剪相片
- 3 自建 HTTPS 证书
- 阿里下一代数据库技术:把数据库装入容器不再是神话
- 搜索-G
- 今天遇到的问题
- 在网页里动态加载 js
- MVC框架(一)----前端框架分类
- 选购四轴飞行器的部件
- Spring中使用两种Aware接口自定义获取bean
- c++中mfc找不到自定义的ID