差異處
這裏顯示兩個版本的差異處。
| 兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
| tech:openssl_caserver [2008/09/16 17:11] – jonathan | tech:openssl_caserver [2025/04/13 00:50] (目前版本) – 移除了 -des3 參數, 將 -sha1 替換為 -sha256 jonathan | ||
|---|---|---|---|
| 行 5: | 行 5: | ||
| ==== - 建立根憑證 Private Key 檔 RootCA.key ==== | ==== - 建立根憑證 Private Key 檔 RootCA.key ==== | ||
| <code sh> | <code sh> | ||
| - | openssl genrsa | + | openssl genrsa -out RootCA.key 2048 |
| chmod og-rwx RootCA.key | chmod og-rwx RootCA.key | ||
| </ | </ | ||
| - | ++++看產生結果| | ||
| - | < | ||
| - | [jonathan@pd920 ca]$ openssl genrsa -des3 -out RootCA.key 2048 | ||
| - | Generating RSA private key, 2048 bit long modulus | ||
| - | ..............................................+++ | ||
| - | .+++ | ||
| - | e is 65537 (0x10001) | ||
| - | Enter pass phrase for RootCA.key: | ||
| - | Verifying - Enter pass phrase for RootCA.key: <-- 再次輸入 RootCA 密鑰的密碼 | ||
| - | [jonathan@pd920 ca]$ chmod og-rwx RootCA.key | ||
| - | </ | ||
| - | ++++ | ||
| ==== - 產生根憑證的申請檔 RootCA.req ==== | ==== - 產生根憑證的申請檔 RootCA.req ==== | ||
| 行 26: | 行 14: | ||
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| - | [jonathan@pd920 ca]$ openssl req -new -key RootCA.key -out RootCA.req | + | $ openssl req -new -key RootCA.key -out RootCA.req |
| - | Enter pass phrase for RootCA.key: <-- 輸入 RootCA 密鑰的密碼 | + | |
| You are about to be asked to enter information that will be incorporated | You are about to be asked to enter information that will be incorporated | ||
| into your certificate request. | into your certificate request. | ||
| 行 36: | 行 23: | ||
| If you enter ' | If you enter ' | ||
| ----- | ----- | ||
| - | Country Name (2 letter code) [GB]:TW | + | Country Name (2 letter code) [AU]:TW |
| - | State or Province Name (full name) [Berkshire]:Taiwan | + | State or Province Name (full name) [Some-State]:Taiwan |
| - | Locality Name (eg, city) [Newbury]:Taipei | + | Locality Name (eg, city) []:Taipei |
| - | Organization Name (eg, company) [My Company | + | Organization Name (eg, company) [Internet Widgits Pty Ltd]: |
| - | Organizational Unit Name (eg, section) []: <-- 可以不輸入 | + | Organizational Unit Name (eg, section) []: |
| - | Common Name (eg, your name or your server' | + | Common Name (e.g. server FQDN or YOUR name) []: |
| Email Address []: | Email Address []: | ||
| Please enter the following ' | Please enter the following ' | ||
| to be sent with your certificate request | to be sent with your certificate request | ||
| - | A challenge password []: <-- 可以不輸入 | + | A challenge password []: |
| - | An optional company name []: <-- 可以不輸入 | + | An optional company name []: |
| - | [jonathan@pd920 ca]$ | + | $ |
| - | </xtermrtf> | + | </cli> |
| ++++ | ++++ | ||
| ==== - 產生效期十年的根憑證檔 RootCA.crt ==== | ==== - 產生效期十年的根憑證檔 RootCA.crt ==== | ||
| <code sh> | <code sh> | ||
| - | openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey RootCA.key -in RootCA.req -out RootCA.crt | + | openssl x509 -req -days 3650 -sha256 |
| - | rm -f RootCA.req | + | |
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| - | [jonathan@pd920 ca]$ openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey RootCA.key -in RootCA.req -out RootCA.crt | + | $ openssl x509 -req -days 3650 -sha256 |
| - | Signature | + | Warning: ignoring -extensions option without -extfile |
| - | subject=/C=TW/ST=Taiwan/L=Taipei/O=Trysoft Corp./[email protected] | + | Certificate request self-signature |
| - | Getting Private key | + | subject=C = TW, ST = Taiwan, L = Taipei, O = Trysoft Corp., emailAddress = [email protected] |
| - | Enter pass phrase for RootCA.key: <-- 輸入 RootCA 密鑰的密碼 | + | $ |
| - | [jonathan@pd920 ca]$ rm -f RootCA.req | + | </cli> |
| - | </xtermrtf> | + | |
| ++++ | ++++ | ||
| - | < | ||
| | {{: | | {{: | ||
| - | </ | ||
| ===== - 伺服器憑證 (Server CA) 作法:===== | ===== - 伺服器憑證 (Server CA) 作法:===== | ||
| 行 76: | 行 59: | ||
| chmod og-rwx ServerCA.key | chmod og-rwx ServerCA.key | ||
| </ | </ | ||
| - | ++++看產生結果| | ||
| - | < | ||
| - | [jonathan@pd920 ca]$ openssl genrsa -out ServerCA.key 2048 | ||
| - | Generating RSA private key, 2048 bit long modulus | ||
| - | .............................................+++ | ||
| - | ...........................................................................................................+++ | ||
| - | e is 65537 (0x10001) | ||
| - | 不會出現輸入密碼的訊息,因為 Server CA 不需要輸入密碼,否則啟動 Service 時會需要輸入密碼後,才可繼續執行服務 | ||
| - | </ | ||
| - | ++++ | ||
| ==== - 產生伺服器憑證的申請檔 ServerCA.req ==== | ==== - 產生伺服器憑證的申請檔 ServerCA.req ==== | ||
| 行 92: | 行 65: | ||
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| - | [jonathan@pd920 ca]$ openssl req -new -key ServerCA.key -out ServerCA.req | + | $ openssl req -new -key ServerCA.key -out ServerCA.req |
| You are about to be asked to enter information that will be incorporated | You are about to be asked to enter information that will be incorporated | ||
| into your certificate request. | into your certificate request. | ||
| 行 101: | 行 74: | ||
| If you enter ' | If you enter ' | ||
| ----- | ----- | ||
| - | Country Name (2 letter code) [GB]:TW | + | Country Name (2 letter code) [AU]:TW |
| - | State or Province Name (full name) [Berkshire]:Taiwan | + | State or Province Name (full name) [Some-State]:Taiwan |
| - | Locality Name (eg, city) [Newbury]:Taipei | + | Locality Name (eg, city) []:Taipei |
| - | Organization Name (eg, company) [My Company | + | Organization Name (eg, company) [Internet Widgits Pty Ltd]: |
| - | Organizational Unit Name (eg, section) []: <-- 可以不輸入 | + | Organizational Unit Name (eg, section) []: |
| - | Common Name (eg, your name or your server's hostname) []: | + | Common Name (e.g. server |
| Email Address []: | Email Address []: | ||
| Please enter the following ' | Please enter the following ' | ||
| to be sent with your certificate request | to be sent with your certificate request | ||
| - | A challenge password []: <-- 可以不輸入 | + | A challenge password []: |
| - | An optional company name []: <-- 可以不輸入 | + | An optional company name []: |
| - | </xtermrtf> | + | $ |
| + | </cli> | ||
| ++++ | ++++ | ||
| ==== - 產生效期兩年的伺服器憑證檔 ServerCA.crt ==== | ==== - 產生效期兩年的伺服器憑證檔 ServerCA.crt ==== | ||
| <code sh> | <code sh> | ||
| - | openssl x509 -req -days 730 -sha1 -extensions v3_req -CA RootCA.crt -CAkey RootCA.key | + | openssl x509 -req -days 730 -sha256 |
| rm -f ServerCA.req | rm -f ServerCA.req | ||
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| - | [jonathan@pd920 ca]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA RootCA.crt -CAkey RootCA.key | + | $ openssl x509 -req -days 730 -sha256 |
| - | Signature | + | Warning: ignoring -extensions option without -extfile |
| - | subject=/C=TW/ST=Taiwan/L=Taipei/O=Trysoft Corp./CN=mail.ichiayi.com/[email protected] | + | Certificate request self-signature |
| - | Getting CA Private Key | + | subject=C = TW, ST = Taiwan, L = Taipei, O = Trysoft Corp., CN = mail.ichiayi.com, emailAddress = [email protected] |
| - | Enter pass phrase for RootCA.key: <-- 輸入 RootCA 密鑰的密碼 | + | $ |
| - | [jonathan@pd920 ca]$ rm -f ServerCA.req | + | </cli> |
| - | </xtermrtf> | + | |
| ++++ | ++++ | ||
| - | < | ||
| | {{: | | {{: | ||
| - | </ | ||
| ===== - 用戶憑證 (Client CA) 作法:===== | ===== - 用戶憑證 (Client CA) 作法:===== | ||
| ==== - 建立用戶憑證 Private Key 檔 ClientCA.key ==== | ==== - 建立用戶憑證 Private Key 檔 ClientCA.key ==== | ||
| <code sh> | <code sh> | ||
| - | openssl genrsa | + | openssl genrsa -out ClientCA.key 2048 |
| chmod og-rwx ClientCA.key | chmod og-rwx ClientCA.key | ||
| </ | </ | ||
| - | ++++看產生結果| | ||
| - | < | ||
| - | [jonathan@pd920 ca]$ openssl genrsa -des3 -out ClientCA.key 2048 | ||
| - | Generating RSA private key, 2048 bit long modulus | ||
| - | ...........+++ | ||
| - | ................................................+++ | ||
| - | e is 65537 (0x10001) | ||
| - | Enter pass phrase for ClientCA.key: | ||
| - | Verifying - Enter pass phrase for ClientCA.key: | ||
| - | [jonathan@pd920 ca]$ chmod og-rwx ClientCA.key | ||
| - | </ | ||
| - | ++++ | ||
| ==== - 產生用戶憑證的申請檔 ClientCA.req ==== | ==== - 產生用戶憑證的申請檔 ClientCA.req ==== | ||
| 行 160: | 行 119: | ||
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| [jonathan@pd920 ca]$ openssl req -new -key ClientCA.key -out ClientCA.req | [jonathan@pd920 ca]$ openssl req -new -key ClientCA.key -out ClientCA.req | ||
| Enter pass phrase for ClientCA.key: | Enter pass phrase for ClientCA.key: | ||
| 行 182: | 行 141: | ||
| A challenge password []: <-- 可以不輸入 | A challenge password []: <-- 可以不輸入 | ||
| An optional company name []: <-- 可以不輸入 | An optional company name []: <-- 可以不輸入 | ||
| - | </xtermrtf> | + | </cli> |
| ++++ | ++++ | ||
| ==== - 產生效期兩年的用戶憑證檔 ClientCA.crt ==== | ==== - 產生效期兩年的用戶憑證檔 ClientCA.crt ==== | ||
| <code sh> | <code sh> | ||
| - | openssl x509 -req -days 730 -sha1 -extensions v3_req -CA RootCA.crt -CAkey RootCA.key | + | openssl x509 -req -days 730 -sha256 |
| rm -f ClientCA.req | rm -f ClientCA.req | ||
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| - | [jonathan@pd920 ca]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA RootCA.crt -CAkey RootCA.key | + | [jonathan@pd920 ca]$ openssl x509 -req -days 730 -sha256 |
| Signature ok | Signature ok | ||
| subject=/ | subject=/ | ||
| 行 198: | 行 157: | ||
| Enter pass phrase for RootCA.key: <-- 輸入 RootCA 密鑰的密碼 | Enter pass phrase for RootCA.key: <-- 輸入 RootCA 密鑰的密碼 | ||
| [jonathan@pd920 ca]$ rm -f ClientCA.req | [jonathan@pd920 ca]$ rm -f ClientCA.req | ||
| - | </xtermrtf> | + | </cli> |
| ++++ | ++++ | ||
| ==== - 將 ClientCA.crt 與 ClientCA.key 轉成 ClientCA.pfx ==== | ==== - 將 ClientCA.crt 與 ClientCA.key 轉成 ClientCA.pfx ==== | ||
| 行 205: | 行 164: | ||
| </ | </ | ||
| ++++看產生結果| | ++++看產生結果| | ||
| - | <xtermrtf> | + | <cli> |
| [jonathan@pd920 ca]$ openssl pkcs12 -export -in ClientCA.crt -inkey ClientCA.key -out ClientCA.pfx | [jonathan@pd920 ca]$ openssl pkcs12 -export -in ClientCA.crt -inkey ClientCA.key -out ClientCA.pfx | ||
| Enter pass phrase for ClientCA.key: | Enter pass phrase for ClientCA.key: | ||
| Enter Export Password: <-- 設定匯出用戶憑證時的密碼, | Enter Export Password: <-- 設定匯出用戶憑證時的密碼, | ||
| Verifying - Enter Export Password: <-- 輸入確認匯出用戶憑證時的密碼 | Verifying - Enter Export Password: <-- 輸入確認匯出用戶憑證時的密碼 | ||
| - | </xtermrtf> | + | </cli> |
| ++++ | ++++ | ||
| 行 216: | 行 175: | ||
| * 看到 apache 的 ssl_request_log 發現 IE7 使用 **TLSv1 RC4-MD5**, Firefox3 使用 **SSLv3 DHE-RSA-AES256-SHA**, | * 看到 apache 的 ssl_request_log 發現 IE7 使用 **TLSv1 RC4-MD5**, Firefox3 使用 **SSLv3 DHE-RSA-AES256-SHA**, | ||
| - | <xtermrtf> | + | <cli> |
| [root@pd920 httpd]# cat ssl_request_log | [root@pd920 httpd]# cat ssl_request_log | ||
| [20/ | [20/ | ||
| 行 222: | 行 181: | ||
| [21/ | [21/ | ||
| [root@pd920 httpd]# | [root@pd920 httpd]# | ||
| - | </xtermrtf> | + | </cli> |
| ===== 參考網址 ===== | ===== 參考網址 ===== | ||