OpenSSl Self-Signed Certificate Generation
底下將透過Ubuntu下的openssl指令產生數位憑證(Certificates),在產生憑證前,你需要用下面的指令產生一把private key,並要求你輸入密碼保護這把key。
$ openssl genrsa -des3 -out server.key 2048
但為了方便起見,最好不要為key設密碼,不然你每次啟動secure services都要輸入密碼,例如你架了一個SSL連線加密保護的Web Server (HTTPS),每次你啟動它的時候都要輸入密碼,萬一你的server主機出問題自動重開機,使用者就無法連到你的Web Server,除非你為key輸入密碼。底下的指令是透上面產生的key再產生一把沒有設密碼的key,至於你要用哪一把就看你囉!如果是我,我會選擇沒設密碼的private key。
$ openssl rsa -in server.key -out server.key.insecure
$ mv server.key server.key.secure
$ mv server.key.insecure server.key
接下來,要產生一張Certificate Signing Request (CSR),指令如下。
$ openssl req -new -key server.key -out server.csr
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]:TW
State or Province Name (full name) [Some-State]:Taiwan
Locality Name (eg, city) []:Kaohsiung City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Renee's Blog
Organizational Unit Name (eg, section) []:Owner
Common Name (e.g. server FQDN or YOUR name) []:reneeciou.blogspot.tw
Email Address []:reneeciou@example.com.tw
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []: