自己署名証明書の作成方法をしらべました。

オレオレ証明書をopensslで作る(詳細版) - ろば電子が詰まっている

を参考にさせてもらいました。

秘密鍵の作成、証明書署名要求の作成

$ openssl genrsa 2048 > server.key
$ openssl req -new -key server.key > server.csr

必要情報を入力

Country Name (2 letter code) [AU]: JP
State or Province Name (full name) [Some-State]: Tokyo
Locality Name (eg, city) []: Bunkyo-ku
Organization Name (eg, company) [Internet Widgits Pty Ltd]: xxx.inc
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:hogehoge.example.com   ←ココ重要!!!!!!!!
Email Address []: xxx@ki-no.org

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

Common Nameについては、使用するサーバ名とあわせておきましょう。

署名

最後に、自分の秘密鍵で署名します。

$ openssl x509 -days 3650 -req -signkey server.key < server.csr > server.crt

以上で自己署名したサーバ証明書が完成です。

pfxファイル作成

ついでに、IIS等で使用する場合に使用されるpfx形式(秘密鍵と証明書が一つになったファイル形式)に変換します

秘密鍵、公開鍵形式からPKCS#12(pfx)形式への変換方法 | GeoTrust

$ openssl pkcs12 -export -inkey server.key -in server.crt -out server.pfx

参考

参考) pfxファイルを key/crt方式へ変換 pfxファイルからopensslでcertファイルへ変換する| prophet STAFF BLOG

 $  openssl pkcs12 -in server.pfx  -clcerts -nokeys -out server.crt    ← 証明書
 $  openssl pkcs12 -in server.pfx  -nocerts -nodes -out server.key   ← 秘密鍵
 $  openssl pkcs12 -in server.pfx  -cacerts -nokeys -out server.ca-bundle ←中間CA(あれば)

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS