0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Nginx: *.pfx を変換して、証明書を使う

Last updated at Posted at 2024-01-24

参考ページ
PKCS#12(pfx)形式から、秘密鍵、公開鍵形式への変換方法

前提

example2024.pfx と パスワードが与えられているとします。

キーペアファイルに変換

openssl pkcs12 -in ./example2024.pfx > keypair.txt

keypair.txt をエディターで2つのファイルに分割

example2024.key.org
example2024.crt

確認

openssl rsa -noout -text -in example2024.key.org
openssl x509 -noout -dates -in example2024.crt

example2024.key.org をパスフレーズなしに変換

openssl rsa -in example2024.key.org -out example2024.key

example2024.key の確認

openssl rsa -noout -text -in example2024.key

サーバーの設定

example2024.key, example2024.crt を、/etc/nginx/certificates に置く

/etc/nginx にシンボリックリンクを作成

cd /etc/nginx
sudo ln -s certificates/example2024.key example.key
sudo ln -s certificates/example2024.crt example.crt

Nginx の設定が正しいか確認

sudo nginx -t

Nginx を再起動

sudo systemctl restart nginx

ブラウザーでアクセスして、有効期限を確認

使用したバージョン

$ openssl --version
OpenSSL 3.3.1 4 Jun 2024 (Library: OpenSSL 3.3.1 4 Jun 2024)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?