mattcoh
(Mattcoh)
April 19, 2023, 6:30am
1
Hello,
I have a DevOps infrastructure for a few of my projects at work, which work as a automated version release/deployment.
During the process of the pipeline (building and deploying the project), the project is built into a docker image. Based on MongoDB:4.2 docker image (Link: MongoDB:4.2 docker image
and during the set-up of the docker image (AKA the dockerfile commands) there is a failure during the apt-get update process. I receive the following error:
#5 23.68 W: GPG error: [MongoDB Repositories](http://repo.mongodb.org/apt/ubuntu) bionic/mongodb-org/4.2 Release: The following signatures were invalid: EXPKEYSIG 4B7C549A058F8B6B MongoDB 4.2 Release Signing Key [packaging@mongodb.com](mailto:packaging@mongodb.com)
I tried allowing unauthorized connections with --allow-unauthenticated in the apt-get command, but still the same error.
I read somewhere this might be on MongoDB’s side and they let the signature expire, and they need to fix this, but I’m unsure whether or not this is correct. (I’m starting to believe it because I’ve tried so many different potential solutions, but nothing works)
Best regards,
Mat
rimelek
(Ákos Takács)
April 19, 2023, 8:24pm
2
Did you open this issue?
opened 05:08PM - 18 Apr 23 UTC
We have started to get this error with the mongo 4.2 tools:
W: GPG error: htt… p://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release: The following signatures were invalid: EXPKEYSIG 4B7C549A058F8B6B MongoDB 4.2 Release Signing Key <packaging@mongodb.com>
I have tried as far back as mongo:4.2.21 with no luck, looks like the key is just expired.
Using official install method e.g. for tools works still:
```
apt-get -y install wget gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
apt-get update && apt-get install -y mongodb-org-tools
```
Full repro:
```
docker run -it --rm mongo:4.2 bash
Unable to find image 'mongo:4.2' locally
4.2: Pulling from library/mongo
cd150c608fee: Pull complete
54f6a3f62677: Pull complete
bb258d6da780: Pull complete
3e9c003e9815: Pull complete
4314b0dc20bd: Pull complete
83c019150967: Pull complete
72c9965543e6: Pull complete
122355f52c71: Pull complete
ef6009f15f12: Pull complete
Digest: sha256:c672722ffc4f724efc525a19c349fc71c9edfb9df8bd83582e82434ac9fda6bb
Status: Downloaded newer image for mongo:4.2
root@5c7a2a8d2f83:/#
root@5c7a2a8d2f83:/#
root@5c7a2a8d2f83:/#
root@5c7a2a8d2f83:/#
root@5c7a2a8d2f83:/# apt update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Ign:2 http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 InRelease
Get:3 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [23.8 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [1497 kB]
Get:5 http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release [3096 B]
Get:6 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1614 kB]
Get:8 http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release.gpg [801 B]
Ign:8 http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release.gpg
Get:9 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [3243 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [83.3 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB]
Get:13 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
Get:15 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [30.8 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [1573 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2392 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [3685 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [20.6 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [64.0 kB]
Reading package lists... Done
W: GPG error: http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release: The following signatures were invalid: EXPKEYSIG 4B7C549A058F8B6B MongoDB 4.2 Release Signing Key <packaging@mongodb.com>
E: The repository 'http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
```
I answered there too. Quote:
It looks like the image was built 8 days ago, but I guess the layer that updates the key was not rebeuilt. Here is the RUN instruction:
I added it to a new Dockerfile and it worked as is.
FROM mongo:4.2
RUN set -ex; \
export GNUPGHOME="$(mktemp -d)"; \
set -- 'E162F504A20CDF15827F718D4B7C549A058F8B6B'; \
for key; do \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys "$key"; \
done; \
mkdir -p /etc/apt/keyrings; \
gpg --batch --export "$@" > /etc/apt/keyrings/mongodb.gpg; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME"
RUN apt-get update