LoginSignup
0
0

githubのUI上で作成したcommitにつけられるgpg署名を検証してみよう

Last updated at Posted at 2024-02-26

初めに

GithubのUI上でcommitを作成すると、githubによってgpg署名されます。

最近は、この場合Committer: GitHub <noreply@github.com>となるようです(Authorが自分の名前)。

さて、最近になって、このgpg鍵は更新されました。

Rotating credentials for GitHub.com and new GHES patches - The GitHub Blog

さて、そんな新しいcommitの署名を検証してみましょう。

検証する準備をする

まずは公開鍵を取ってこないといけません。gpg --recv-keysしてもいいのですが、せっかくGithubが公開鍵をホストしてくれているのでこれを使います。

Rotating credentials for GitHub.com and new GHES patches - The GitHub Blog

What you need to do

If you verify GitHub.com commits outside of GitHub, including for verification in GHES, you will need to import our new public key hosted here.

と書いているのでこれをimportします。

$curl https://github.com/web-flow.gpg | gpg --import
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2483  100  2483    0     0   6002      0 --:--:-- --:--:-- --:--:--  6070
gpg: 鍵4AEE18F83AFDEB23: 公開鍵"GitHub (web-flow commit signing) <noreply@github.com>"をインポートしました
gpg: 鍵B5690EEEBB952194: 公開鍵"GitHub <noreply@github.com>"をインポートしました
gpg:           処理数の合計: 2
gpg:             インポート: 2
$gpg -k
/home/yumetodo/.gnupg/pubring.kbx
----------------------------------
pub   ed25519 2019-03-28 [SC] [有効期限: 2024-03-26]
      734D8C6306B6F43A6FBFD64C099948A245901ACB
uid           [  究極  ] yumetodo <yume-wikijp@live.jp>

pub   rsa2048 2017-08-16 [SC] [期限切れ: 2024-01-16]
      5DE3E0509C47EA3CF04A42D34AEE18F83AFDEB23
uid           [期限切れ] GitHub (web-flow commit signing) <noreply@github.com>

pub   rsa4096 2024-01-16 [SC]
      968479A1AFF927E37D1A566BB5690EEEBB952194
uid           [  不明  ] GitHub <noreply@github.com>
$gpg --edit-key 968479A1AFF927E37D1A566BB5690EEEBB952194 trust
gpg (GnuPG) 2.4.4; Copyright (C) 2024 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


pub  rsa4096/B5690EEEBB952194
     作成: 2024-01-16  有効期限: 無期限      利用法: SC
     信用: 不明の     有効性: 不明の
[  不明  ] (1). GitHub <noreply@github.com>

pub  rsa4096/B5690EEEBB952194
     作成: 2024-01-16  有効期限: 無期限      利用法: SC
     信用: 不明の     有効性: 不明の
[  不明  ] (1). GitHub <noreply@github.com>

他のユーザの鍵を正しく検証するために、このユーザの信用度を決めてください
(パスポートを見せてもらったり、他から得たフィンガープリントを検査したり、などなど)

  1 = 知らない、または何とも言えない
  2 = 信用し ない
  3 = まぁまぁ信用する
  4 = 充分に信用する
  5 = 究極的に信用する
  m = メーン・メニューに戻る

あなたの決定は? 5
本当にこの鍵を究極的に信用しますか? (y/N) y

pub  rsa4096/B5690EEEBB952194
     作成: 2024-01-16  有効期限: 無期限      利用法: SC
     信用: 究極        有効性: 不明の
[  不明  ] (1). GitHub <noreply@github.com>
プログラムを再起動するまで、表示された鍵の有効性は正しくないかもしれない、
ということを念頭においてください。

gpg> quit
$gpg -k
/home/yumetodo/.gnupg/pubring.kbx
----------------------------------
pub   ed25519 2019-03-28 [SC] [有効期限: 2024-03-26]
      734D8C6306B6F43A6FBFD64C099948A245901ACB
uid           [  究極  ] yumetodo <yume-wikijp@live.jp>

pub   rsa2048 2017-08-16 [SC] [期限切れ: 2024-01-16]
      5DE3E0509C47EA3CF04A42D34AEE18F83AFDEB23
uid           [期限切れ] GitHub (web-flow commit signing) <noreply@github.com>

pub   rsa4096 2024-01-16 [SC]
      968479A1AFF927E37D1A566BB5690EEEBB952194
uid           [  究極  ] GitHub <noreply@github.com>

検証する

今回はcpprefjpのrepoで試してみましょう

$git remote -v
origin  git@github.com:cpprefjp/site.git (fetch) [blob:none]
origin  git@github.com:cpprefjp/site.git (push)
$git log --show-signature -n 1 --pretty=full f49fe9995fcff4e7ee8ed9e5af5ff25f37204aaf
commit f49fe9995fcff4e7ee8ed9e5af5ff25f37204aaf
gpg: 2024年02月19日 23時01分17秒 JSTに施された署名
gpg:                RSA鍵B5690EEEBB952194を使用
gpg: "GitHub <noreply@github.com>"からの正しい署名 [究極]
Author: yumetodo <yume-wikijp@live.jp>
Commit: GitHub <noreply@github.com>

    fix(ci): 結果をartifactに保存してみる (#1250)

検証できましたね。

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