網頁

2023/11/7

Mac 使用OpenSSL產生自簽憑證

Mac使用OpenSSL設定HTTPS連線的方式如下。。


範例環境:

  • MacBook M1
  • macOS Ventura 13.01


建立自簽憑證

在命令列輸入openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem會在執行目錄產生自簽憑證cert.pem與金鑰key.pem

% openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout key.pem -out cert.pem
Generating a 2048 bit RSA private key
................................................................+++++
...............................+++++
writing new private key to 'key.pem'
-----
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) []:TW
State or Province Name (full name) []:Taiwan
Locality Name (eg, city) []:Taipei
Organization Name (eg, company) []:ABC Inc.
Organizational Unit Name (eg, section) []:Dev
Common Name (eg, fully qualified host name) []:abc.com
Email Address []:john@abc.com

沒有留言:

張貼留言