3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitLabが署名の鍵の期限切れでアップデートできなかったのを解消した話

Last updated at Posted at 2024-03-12

毎度、ググっても出てこない小ネタを取り扱っております。
本記事は個人的な見解であり、筆者の所属するいかなる団体にも関係ございません。

GitLab Runnerは以下の方法では署名の鍵の期限切れはアップデートできなかったので以下の記事を書きました。

GitLab Runnerが署名の鍵の期限切れでアップデートできなかったのを解消した話 #GitLab - Qiita
https://qiita.com/ynott/items/0780a60f004270a15776

0. はじめに

昨年と一昨年に以下の記事を書きました。

【解決済み】GitLab Omnibus が署名の鍵の期限切れでアップデートできなかったのを解消した話 #GitLab - Qiita
https://qiita.com/ynott/items/f347b66d0902f23fc1d7

GitLabとRunnerが署名の鍵の期限切れでアップデートできなかったのを解消した話 #GitLab - Qiita
https://qiita.com/ynott/items/f344e89ba5f88568d862

UbuntuでGitLabを動かしていますが、証明書の期限切れでアップデートが落ちてこなくなっていたので、それを解消したという話になります。

1. どうなっていたか?

証明書が切れるとsudo apt updateが以下のようになります。

user@gitlab:~$ sudo apt update
[sudo] user のパスワード:
ヒット:2 http://jp.archive.ubuntu.com/ubuntu jammy InRelease
取得:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [110 kB]     
取得:4 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
取得:5 https://esm.ubuntu.com/infra/ubuntu jammy-infra-security InRelease [7,450 B]                                             
取得:6 https://esm.ubuntu.com/infra/ubuntu jammy-infra-updates InRelease [7,449 B]             
ヒット:7 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease
取得:8 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages [586 kB]
取得:1 https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu jammy InRelease [23.4 kB]
エラー:1 https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu jammy InRelease
  以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@gitlab.com>
取得:9 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [1,461 kB]
取得:10 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main Translation-en [284 kB]
取得:11 http://jp.archive.ubuntu.com/ubuntu jammy-updates/restricted Translation-en [259 kB]
取得:12 http://jp.archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1,054 kB]
取得:13 http://jp.archive.ubuntu.com/ubuntu jammy-updates/universe i386 Packages [694 kB]
取得:14 http://jp.archive.ubuntu.com/ubuntu jammy-updates/universe Translation-en [237 kB]
4,844 kB  5 で取得しました (1,067 kB/s)
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
アップグレードできるパッケージが 22 個あります。表示するには 'apt list --upgradable' を実行してください。
W: 署名照合中にエラーが発生しました。リポジトリは更新されず、過去のインデックスファイルが使われます。GPG エラー: https://packages.gubuntu jammy InRelease: 以下の署名が無効です: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) <packages@git
W: https://packages.gitlab.com/gitlab/gitlab-ee/ubuntu/dists/jammy/InRelease の取得に失敗しました  以下の署名が無効です: EXPKEYSIG. (package repository signing key) <packages@gitlab.com>
W: いくつかのインデックスファイルのダウンロードに失敗しました。これらは無視されるか、古いものが代わりに使われます。

アップデートのインデックスが更新されないので、新しいアップデートがあってもバージョンアップ対象として出てきません。

2. どうするか?

以下に従って鍵を更新します。

Cryptographic details related to omnibus-gitlab packages | GitLab
https://docs.gitlab.com/omnibus/update/package_signatures.html#update-keys-after-expiry-extension

2-1. apt-key または signed-by のどちらを使用しているかどうかを確認

Ubuntuのパッケージ認証方式は、apt-keysigned-byの2つの方式があります。
apt-keyが古い方式でsigned-byが新しい方式です。徐々にsigned-byに切り替わっている途中かと思います。

まず、どちらを使っているか以下のコマンドで確認します。

grep 'deb \[signed-by=' /etc/apt/sources.list.d/gitlab_gitlab-?e.list

以下のような結果が返ってきた場合は、signed-byを使っています。
image.png

2-2. signed-by形式の鍵を更新する

ルート権限で以下のコマンドを実行してください。

 awk '/deb \[signed-by=/{
       pubkey = $2;
       sub(/\[signed-by=/, "", pubkey);
       sub(/\]$/, "", pubkey);
       print pubkey
     }' /etc/apt/sources.list.d/gitlab_gitlab-?e.list | \
   while read line; do
     curl -s "https://packages.gitlab.com/gpg.key" | gpg --dearmor > $line
   done

何も表示されませんが、実行エラーがないかどうかだけ確認しておきます。
image.png

3. 更新できたか確認

2-2.で何も返ってきていませんでしたが、更新できていればapt updateが成功するはずです。
実行してみます。

エラーなく実行終了しました。

image.png

4. まとめ

特になし

3
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?