nginx的https安全认证CA
生活随笔
收集整理的這篇文章主要介紹了
nginx的https安全认证CA
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
介紹
安全認證稱CA,CA分為兩種一種是私有CA另一種是共有CA。
- 私有CA不被公網所承認,是自己做實驗時可以使用。
- 共網CA被公網承認的證書,需要通過阿里云等途徑購買。
CA詳細解釋
私有CA的搭建
實驗環境
- 關閉防火墻
- 關閉selinux
- 網絡環境(注意:沒網環境下需要提前下載nginx安裝包)
- 虛擬主機一臺,安裝nginx軟件(注意:編譯安裝是需要安裝一個模塊 --with-http_ssl_module)
實驗步驟
實現開始
1. 準備存放證書和密鑰的目錄 [root@localhost web]# mkdir /etc/nginx/ssl 2. 生成密鑰 [root@localhost web]# openssl genrsa 2048 > /etc/nginx/ssl/server.key ##生成一個長度為2048長度的密鑰到/ect/nginx/ssl/server.key文件中 Generating RSA private key, 2048 bit long modulus .....+++ ..........................+++ e is 65537 (0x10001)[root@localhost web]# openssl req -new -key /etc/nginx/ssl/server.key > /etc/nginx/ssl/server.csr ##基于server.key生成一個密鑰 3. 使用密鑰文件生成證書-申請書 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) [XX]:CN ##國家名稱 State or Province Name (full name) []:HB ##省名稱 Locality Name (eg, city) [Default City]:HD ##默認城市 Organization Name (eg, company) [Default Company Ltd]:QF ##默認公司 Organizational Unit Name (eg, section) []:CLOUD ##組織單位名稱 Common Name (eg, your name or your server's hostname) []:NGINX.LINUX.COM ##服務器的名字 Email Address []:2570426390@qq.com ##聯系郵箱 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ##挑戰密碼 An optional company name []: ##一個可選的公司名稱 4. 同意申請,生成證書 [root@localhost web]# openssl req -x509 -days 365 -key /etc/nginx/ssl/server.key -in /etc/nginx/ssl/server.csr > /etc/nginx/ssl/server.crt ##生成密鑰格式為x509,有效時間為365,密鑰位置,證書的申請書,認證證書位置 5. 配置文件,重啟nginx [root@localhost ~]# vim /etc/nginx/conf.d/web.conf ##修改配置文件 server { ##服務模塊listen 443 ssl; ##監聽端口,443端口是ssl加密認證的默認端口server_name www.web1.com; ##網站服務域名ssl_certificate /etc/nginx/ssl/server.crt; ##安全證書位置ssl_certificate_key /etc/nginx/ssl/server.key; ##安全證書密鑰location / { ##url資源地址定位root /web/web1; ##網站默認訪問位置index index.html; ##默認首頁格式} } [root@localhost ~]# mkdir -p /web/web1 ##創建目錄 [root@localhost ~]# echo “in hao wo shi web1” > /web/web1/index.html ##寫html首頁 [root@localhost ~]# nginx -s reload ##重新加載nginx總結
以上是生活随笔為你收集整理的nginx的https安全认证CA的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 无源晶振匹配电容—计算方法
- 下一篇: ANSYS有限元仿真分析:大变形(Lar