LoginSignup
2
1

More than 1 year has passed since last update.

Gnus で S/MIME 署名を行うための設定

Last updated at Posted at 2022-01-28

Gnus で S/MIME 署名を行うためには,OpenSSL を使う方法と GnuPG(に同梱されている gpgsm コマンド)を使う方法の2通りがある.EmacsWiki では,まだ OpenSSL での設定方法が最初に紹介されている.しかし,mml-smime-use 変数のドキュメントには以下のように記載があるため,gpgsm コマンドを使う方法を検討する.

If you’re thinking about using OpenSSL, please first read the BUGS section in the manual for the ‘smime’ command that comes with OpenSSL.
We recommend EasyPG.

最初に,クライアント証明書を import しなければならないのだが,ここでつまずく.

$ gpgsm -v --import keycert.p12
gpgsm: data error at "data.objectidentifier", offset 67
gpgsm: error at "bag-sequence", offset 49
gpgsm: error parsing or decrypting the PKCS#12 file
gpgsm:     処理数の合計: 0

Mew のマニュアルにしたがって,OpenSSL を使って,秘密鍵と公開鍵を個別に取り出して import せねばならないらしい.

クライアント証明書の形式をPEM形式に変換し,秘密鍵を取り出して,秘密鍵を import する.

$ openssl pkcs12 -in keycert.p12 -out keycert.pem -nodes
$ openssl pkcs12 -in keycert.pem -export -out key.p12 -nocerts -nodes
$ gpgsm -v --import key.p12

次に,公開鍵を取り出して,公開鍵を import する.

$ openssl pkcs12 -in keycert.p12 -out certs.pem -nokeys
$ gpgsm -v --import certs.pem

正常に import できていれば,以下のコマンドで確認できるはず.

$ gpgsm -kv

確認した証明書の鍵 ID を使って署名するように,以下のように設定しておく.

(setq mml-secure-smime-signers '("XXXXXXXXX"))
2
1
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
2
1