使用OpenSSL生成證書
使用OpenSSL生成證照
下載安裝openssl,進入/bin/下面,執行命令(把ssl目錄下的openssl.cnf 拷貝到bin目錄下) 1.首先要生成伺服器端的私鑰(key檔案): openssl genrsa -des3 -out server.key 1024 [root@airwaySSL openssl]# cd ssl/ [root@airwaySSL ssl]# pwd /home/openssl/ssl [root@airwaySSL ssl]# ls certs man misc openssl.cnf private server.csr server.key 執行時會提示輸入密碼,此密碼用於加密key檔案(引數des3便是指加密演算法,當然也可以選用其他你認為安全的演算法.),以後每當需讀取此檔案(通過openssl提供的命令或API)都需輸入口令.如果覺得不方便,也可以去除這個口令,但一定要採取其他的保護措施! 去除key檔案口令的命令: openssl rsa -in server.key -out server.key 2.openssl req -new -key server.key -out server.csr -config openssl.cnf [root@airwaySSL bin]# openssl req -new -key server.key -out server.csr -config openssl.cnf Enter pass phrase for server.key:12345 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) [AU]:CN State or Province Name (full name) [Some-State]:china Locality Name (eg, city) []:wuhan Organization Name (eg, company) [Internet Widgits Pty Ltd]:airway Organizational Unit Name (eg, section) []:airway Common Name (eg, YOUR name) []:airway Email Address []:
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
生成Certificate Signing Request(CSR),生成的csr檔案交給CA簽名後形成服務端自己的證照.螢幕上將有提示,依照其指示一步一步輸入要求的個人資訊即可. 3.對客戶端也作同樣的命令生成key及csr檔案: openssl genrsa -des3 -out client.key 1024
Generating RSA private key, 1024 bit long modulus ...........++++++ ..++++++ e is 65537 (0x10001) Enter pass phrase for client.key:12345 Verifying - Enter pass phrase for client.key:12345
openssl req -new -key client.key -out client.csr -config openssl.cnf
[root@airwaySSL bin]# openssl req -new -key client.key -out client.csr -config openssl.cnf Enter pass phrase for client.key:12345 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) [AU]:cn State or Province Name (full name) [Some-State]:china Locality Name (eg, city) []:wuhan Organization Name (eg, company) [Internet Widgits Pty Ltd]:airway Organizational Unit Name (eg, section) []:airway Common Name (eg, YOUR name) []:airway Email Address []:
Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []:
4.CSR檔案必須有CA的簽名才可形成證照.可將此檔案傳送到verisign等地方由它驗證,要交一大筆錢,何不自己做CA呢. openssl req -new -x509 -keyout ca.key -out ca.crt -config openssl.cnf
[root@airwaySSL bin]# openssl req -new -x509 -keyout ca.key -out ca.crt -config openssl.cnf Generating a 1024 bit RSA private key ...++++++ ...................++++++ writing new private key to 'ca.key' Enter PEM pass phrase:12345 Verifying - Enter PEM pass phrase: ----- 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) [AU]:CN State or Province Name (full name) [Some-State]:china Locality Name (eg, city) []:wuhan Organization Name (eg, company) [Internet Widgits Pty Ltd]:airway Organizational Unit Name (eg, section) []:airway Common Name (eg, YOUR name) []:airway Email Address []: 在繼續下面操作前,將openssl.conf檔案開啟,檢視其dir路徑將其修改為dir =/home/openssl/bin/demoCA /,否則下面的步驟會提示路徑無法找到。
自己手動建立一個CA目錄結構: 5.用生成的CA的證照為剛才生成的server.csr,client.csr檔案簽名: openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cnf
[root@airwaySSL bin]# openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cnf Using configuration from openssl.cnf Enter pass phrase for ca.key: Check that the request matches the signature Signature ok Certificate Details: Serial Number: 1 (0x1) Validity Not Before: Feb 26 04:15:02 2009 GMT Not After : Feb 26 04:15:02 2010 GMT Subject: countryName = CN stateOrProvinceName = china organizationName = airway organizationalUnitName = airway commonName = airway X509v3 extensions: X509v3 Basic Constraints: CA:FALSE Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: 30:70:D2:EB:9B:73:AE:7B:0E:8E:F6:94:33:7C:53:5B:EF:93:FC:38 X509v3 Authority Key Identifier: keyid:DB:D6:83:BB:7F:28:C2:A9:40:6A:D8:32:FC:01:E0:5C:48:27:51:19
Certificate is to be certified until Feb 26 04:15:02 2010 GMT (365 days) Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y Write out database with 1 new entries Data Base Updated
openssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key -config openssl.cnf
[root@airwaySSL bin]# openssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key -config openssl.cnf Using configuration from openssl.cnf Enter pass phrase for ca.key: Check that the request matches the signature Signature ok The countryName field needed to be the same in the CA certificate (CN) and the request (cn) 現在我們所需的全部檔案便生成了. 另: client使用的檔案有:ca.crt,client.crt,client.key server使用的檔案有:ca.crt,server.crt,server.key |
相關文章
- mac 上使用OpenSSL 生成RSA證書Mac
- 使用OpenSSL生成SANs證書實操
- 使用OpenSSL生成自簽名SSL證書
- openssl生成自簽名證書
- 使用OpenSSL建立生成CA證書、伺服器、客戶端證書及金鑰伺服器客戶端
- OpenSSL 生成 RootCA (根證書)並自簽署證書(支援 IP 地址)
- https--OpenSSL生成root CA及簽發證書HTTP
- centos下 openssl 生成區域網ip的https證書CentOSHTTP
- openssl 證書生成筆記(go 1.15版本以上)筆記Go
- 使用 OpenSSL 建立私有 CA:1 根證書
- openssl 簽發證書
- 使用 OpenSSL 建立私有 CA:3 使用者證書
- fabric-ca載入openssl生成的ecdsa標準證書
- 使用 OpenSSL 建立私有 CA:2 中間證書
- 【加解密】使用CFSSL生成證書並使用gRPC驗證證書解密RPC
- 如何使用Docker生成SSL證書Docker
- 生成https證書HTTP
- Openssl 設定 雙向認證證書的過程
- RSA的主場-證書籤名&OpenSSL演示
- php使用openssl生成公鑰私鑰PHP
- 記錄 openssl 證書驗證失敗的詭異問題
- 使用openssl生成rsa公鑰和私鑰
- SSL證書生成,完成HTTPS驗證HTTP
- Net8 使用BouncyCastle 生成自簽名證書AST
- 重新生成https證書HTTP
- 在Linux下如何根據域名自簽發OpenSSL證書與常用證書轉換Linux
- Mac 使用openssl生成RSA公鑰和私鑰Mac
- cmake openssl 生成失敗
- 使用 acme.sh 為網站生成永久免費證書ACM網站
- 使用OpenSSH證書認證
- HTTPS-自己生成數字證書HTTP
- 線上生成ios證書的流程iOS
- openSSL生成公鑰和私鑰
- OpenSSL工具生成RSA金鑰對
- Kubernetes安裝之二:根證書生成
- acme.sh 生成免費 ssl 證書ACM
- 基於Let's Encrypt生成免費證書-支援多域名泛域名證書
- openssl命令使用
- 用OpenSSL把二進位制的Cer證書轉換程Base64格式的PEM格式的證書