Gitlab-ce Update Failing

Support,

I’m unable to update my Gitlab-ce install due to bad keys being detected. Is this a Gitlab update issue or something gone wrong on my system? I had to replace https:// with (url) to get this message to post.

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: (url): The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: (url): The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: (url): The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Failed to fetch (url) The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Failed to fetch (url) The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Failed to fetch (url) The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Some index files failed to download. They have been ignored, or old ones used instead.

1 Like

Do this:

curl -s https://packages.gitlab.com/gpg.key | apt-key add -
apt-get update

that worked for me on Debian 10 and Debian 11, so should work for you assuming you use Debian/Ubuntu.

This post should also provide extra info: Omnibus-gitlab packages gpg key expired - #6 by twk3 which provides this Gitlab doc: Cryptographic details related to `omnibus-gitlab` packages | GitLab

And this one: GitLab GPG expired today (#6701) · Issues · GitLab.org / omnibus-gitlab · GitLab of which worked for me using the two commands I gave above.

7 Likes

Thanks!

That fixed the bad keys messages when doing an update.

1 Like

Running into the same issue. Is there any official page which provides information when the keys are refreshed or changed?

@L91 in my post above are links to Gitlab documentation as well as the Gitlab issue where the problem was being looked at. Both are official links. There is also that link as well pulled from the forum post that was also linked: Cryptographic details related to `omnibus-gitlab` packages | GitLab

I get ‘gpg: no valid OpenPGP data found’, but ackwardly enough i can do upgrade(ubuntu 18LTS)

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead

I think, the problem is back again

Err:9 https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease
Následující podpisy jsou neplatné: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
Mám:10 https://packages.gitlab.com/runner/gitlab-runner/ubuntu jammy InRelease
Err:10 https://packages.gitlab.com/runner/gitlab-runner/ubuntu jammy InRelease
Následující podpisy jsou neplatné: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
Načítají se seznamy balíků… Hotovo
Vytváří se strom závislostí… Hotovo
Načítají se stavové informace… Hotovo
Všechny balíky jsou aktuální.
W: Při ověřování podpisů se objevila chyba. Repositář není aktualizovaný, tudíž se použijí předchozí indexové soubory. Chyba GPG: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu focal InRelease: Následující podpisy jsou neplatné: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Při ověřování podpisů se objevila chyba. Repositář není aktualizovaný, tudíž se použijí předchozí indexové soubory. Chyba GPG: https://packages.gitlab.com/runner/gitlab-runner/ubuntu jammy InRelease: Následující podpisy jsou neplatné: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Selhalo stažení https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/focal/InRelease Následující podpisy jsou neplatné: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Selhalo stažení https://packages.gitlab.com/runner/gitlab-runner/ubuntu/dists/jammy/InRelease Následující podpisy jsou neplatné: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com
W: Některé indexové soubory se nepodařilo stáhnout. Jsou ignorovány, nebo jsou použity starší verze.

I found the issue that may happen for some people. My /etc/apt/sources.list.d/gitlab_gitlab-ce.list file contained the following entries:

deb [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main
deb-src [signed-by=/usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg] https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main

As you can see the signing key is specified here and it is the expired one. Removing the [signed-by=...] config or replacing the gpg key file with the proper one fixes the issue.

1 Like

There was a similar question in this issue, where someone shared instructions to fix the increased key validity. GitLab GPG expired today (#6701) · Issues · GitLab.org / omnibus-gitlab · GitLab

2 Likes

In general as of 2024 all apt-key operations fail to resolve this issue, especially if gitlab was installed some time ago.

To fix, remove existing apt-key:

sudo apt-key del "F640 3F65 44A3 8863 DAA0 B6E0 3F01 618A 5131 2F3F"

and run latest gitlab install script:

curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash

This resolves gpg error:
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.gitlab.com/runner/gitlab-runner/debian bookworm InRelease: The following signatures were invalid: EXPKEYSIG 3F01618A51312F3F GitLab B.V. (package repository signing key) packages@gitlab.com

More details on root cause are here apt - gitlab-runner update failed with GPG error signatures were invalid - Stack Overflow

4 Likes

curl -s https://packages.gitlab.com/gpg.key | apt-key add -

and

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead

This approach is indeed depricated. apt-key manages the keyring in /etc/apt/trusted.gpg (for Debian), while Gitlab (provided your installation is a bit more recent) does so in /usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg.

In general as of 2024 all apt-key operations fail to resolve this issue, especially if gitlab was installed some time ago.

As @certifieddook noted, if your /etc/apt/sources.list.d/gitlab_gitlab-ce.list file contains a reference to the Gitlab keyring file, the apt-key command will not work.

To download the new gitlab gpg key and add it to the gitlab keyring in one command use this:

wget -qO- https://packages.gitlab.com/gpg.key | gpg --no-default-keyring --keyring /usr/share/keyrings/gitlab_gitlab-ce-archive-keyring.gpg --import

I faced the same problem today and wanted to understand why this keeps happening (rather rarely, but I have seen this kind of error - not for gitlab but other tools - several times over the years. This detailed blogpost about the expired signature key for Gitlab explains it in great detail.

Long story short, apt packages are signed with gpg in order to prevent a man in the middle of exchanging the apt package you want from gitlab with one that contains malicious code. As the workstations used by the Gitlab people are very high value targets, but do get re-installed with new operating systems every now and then, it is common practice to let the private keys that sign the apt packages expire after a few years, and to generate new ones.

2 Likes

Note: for those using GitLab EE, the one-liner is:

wget -qO- https://packages.gitlab.com/gpg.key | gpg --no-default-keyring --keyring /usr/share/keyrings/gitlab_gitlab-ee-archive-keyring.gpg --import
1 Like

almost perfect
there is one more step :

curl -s https://packages.gitlab.com/gpg.key | apt-key add -
sudo cd  /etc/apt/
sudo mv  trusted.gpg  trusted.gpg.d/gitlab-ee-key.gpg

1 Like

This is how I did it:

sudo apt-key del "F640 3F65 44A3 8863 DAA0 B6E0 3F01 618A 5131 2F3F"
curl -s https://packages.gitlab.com/gpg.key | sudo apt-key add -