Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch not working on centOS stream. gives a key import error. #85876

Closed
ingenium21 opened this issue Apr 13, 2022 · 56 comments
Assignees
Labels
>bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team

Comments

@ingenium21
Copy link

Elasticsearch Version

doesn't matter

Installed Plugins

none

Java Version

bundled

OS Version

5.14.0-75.el9.x86_64 #1 SMP PREEMPT Sat Mar 26 08:10:05 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Problem Description

I am trying to install elasticsearch in a centOS stream using rpm and following elastic's own directions.
When I try to import the gpg key using rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch I get a 'key 1 import failed' error. using -v doesn't give me anything useful either.

Steps to Reproduce

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

Logs (if relevant)

No response

@ingenium21 ingenium21 added >bug needs:triage Requires assignment of a team area label labels Apr 13, 2022
@pquentin pquentin added :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team and removed needs:triage Requires assignment of a team area label labels Apr 14, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

@breskeby
Copy link
Contributor

@ingenium21 which elasticsearch version did you try to install?

@breskeby breskeby self-assigned this Apr 14, 2022
@ingenium21
Copy link
Author

Newest version, but I couldn't even get to that part as importing the keys failed

@breskeby
Copy link
Contributor

ah I see

@ingenium21
Copy link
Author

I was able to get around it by change gpgcheck=1 to gpgcheck=0 in the elasticsearch.repo file. But yes, ideally I would like to be installing applications with a valid gpg check.

@breskeby
Copy link
Contributor

Thanks again for bringing this up. I think what we see is an issue introduced by rpm-software-management/rpm#1788

@ingenium21
Copy link
Author

No problem. Happy to support such a cool product. 👍

@cisco-abrandel
Copy link

Seeing the same issue on Alma 9, and I believe you are correct in that changes to RPM are causing this.

@nerijus
Copy link

nerijus commented Jun 8, 2022

A workaround on CentOS 9 is to run update-crypto-policies --set LEGACY.

@cisco-abrandel
Copy link

Thanks for the tip, thats a better workaround than disabling GPG checks entirely

@ingenium21
Copy link
Author

ingenium21 commented Jun 9, 2022 via email

@hrw
Copy link

hrw commented Sep 2, 2022

Will something happen here or should we just mark ELK stack as dead on RHEL9 family of systems?

@mark-vieira
Copy link
Contributor

I'm reaching out to our release engineering team to get a status update on this. We should be able to update the signing key to sort out this problem.

@hrw
Copy link

hrw commented Sep 8, 2022

@mark-vieira so how it went?

@mark-vieira
Copy link
Contributor

We're trying to figure out what exactly needs to be done here. It seems you cannot remove SHA-1 as a supported algorithm from a PGP key. It's actually mandatory according to the spec. I think the issue is the actual signature of the key itself, which implies we'll have to generate a new one and that has the potential to be disruptive for existing users. We're looking at how to sort this out in a backwards-compatible way.

@hrw
Copy link

hrw commented Sep 9, 2022

Not tried, but maybe this can help: https://old.nixaid.com/gpg-migration-sha1-to-sha2/ a bit?

Other idea: what about creating second key (modern one) and use it for signing rhel9 repo first (as you lack them anyway) and choose a date to switch old repos to a new key?

@jameswiggins
Copy link

I'm having the same problem installing logstash on Rocky Linux 9. The workaround from a redhat.com blog post:

  1. As @nerijus mentioned, switch to legacy crypto policy: update-crypto-policies --set LEGACY OR Explicitly allow SHA-1: update-crypto-policies --set DEFAULT:SHA1
  2. Install whatever you need. I need to install logstash so: dnf install logstash
  3. Switch back: update-crypto-policies --set DEFAULT

@ingenium21
Copy link
Author

Thanks james. I was considering moving to Rocky Linux 9 recently. good to know it's happening there too.

@hrw
Copy link

hrw commented Sep 21, 2022

It is problem on each RHEL9 rebuild. Alma Linux, Rocky Linux, Euro Linux etc.

@inputvalidation
Copy link

Checking in to see if this is still progressing? We have customers where we can't disable or allow SHA1 anymore due to security policies.

@ingenium21
Copy link
Author

The fix isn't really a fix but rather a workaround and I believe just disables the security or installs with a less secure GPG key.

@Nirjonadda
Copy link

Do you have any plan add support for AlmaLinux OS 9? Can not install Elasticsearch in AlmaLinux OS 9 because RPM signing key is invalid.

@ingenium21
Copy link
Author

ingenium21 commented Jul 20, 2023 via email

@keys1234249
Copy link

Bump it would be great to not have to use workarounds to install this key in EL9 systems.

@ronald-den-otter
Copy link

SHA1 is not advisable since 2014 something. Why didn't elasticsearch wakeup. Packages need to be resigned. Switching to legacy is the wrong way in my opinion

@Nirjonadda
Copy link

This issue created in Apr 13, 2022 but still no fix happened after more 1 years now.

@chrisberkhout
Copy link
Contributor

@elastic/release-eng Here's a way to fix the SHA1 signatures without migrating to a new key:
https://github.com/chrisberkhout/sha1-key-fix/blob/master/SHA1KeyFix.ipynb

@ronald-den-otter
Copy link

Thinks this is more the way : https://access.redhat.com/solutions/185173
summarized:
gpg --gen-key
gpg -a --export KEYID > /root/CUSTOMER-GPG-KEY
~/.rpmmacros
%_signature gpg
%_gpg_name KEYID
rpm --resign rpmname.rpm

And share GPG-KEY and resigned RPM in new repository

@tr0k
Copy link

tr0k commented Sep 6, 2023

Hello, is there any plan to fix this issue? We need a manual workaround when installing the RPMs in our RHEL9 hosts. That would be very much appreciated.

@alpar-t
Copy link
Contributor

alpar-t commented Sep 7, 2023

We're working on a solution and hope to have something soon.

@mmoser-aires
Copy link

mmoser-aires commented Sep 15, 2023

@alpar-t ,

As @ronald-den-otter pointed out, via this article (Which is dated over 3 years ago...) just resign the packages.

Rotating GPG keys/resigning packages does not require a new product release, you just have to generate a new gpg private key using modern algorithms, resign the packages and publish the public key.

From your side all you have to do is:

gpg --gen-key
gpg -a --export KEYID > RPM-GPG-KEY-ELASTICSEARCH
for i in `ls *.rpm`;do rpm --resign $i;done
cp  RPM-GPG-KEY-ELASTICSEARCH /var/www/html/   # Or wherever your document root is for https://artifacts.elastic.co/

Update your documentation to include the new URL to the new key along with the following command:

rpm -e gpg-pubkey-d88e42b4-52371eca

The above could actually be part of the a minor rpm release to install the new and remove the old for an unattended/automatic update.

GPG key rotation does not require a new release of your software, package distributors rotate GPG keys all of the time, nVidia regular resigns for security purposes. Making this fix contingent on your next software release is a self imposed restriction for a problem that RedHat provided guidance for 3 years ago and this github issue has been open since April of 2022...

Can we please get these packages updated soon?

@mcarifio
Copy link

Problem appears in Rocky Linux 9.2 with elasticsearch-8.10.1. https://www.redhat.com/en/blog/rhel-security-sha-1-package-signatures-distrusted-rhel-9 and the comments above provide more context.

@alpar-t
Copy link
Contributor

alpar-t commented Sep 25, 2023

We just updated https://artifacts.elastic.co/GPG-KEY-elasticsearch to have a signature that works on RHEL 9 and similar. Note that this only changes the algorithms that were problematic and is not a key rotation. Thanks to @chrisberkhout for the suggestion.

@alpar-t alpar-t closed this as completed Sep 25, 2023
kpollich added a commit to elastic/kibana that referenced this issue Oct 2, 2023
## Summary

Ref elastic/elasticsearch#85876
Fixes #167153

The public Elastic GPG key has been updated to use sha256 instead of
sha1 for its hashing algorithm. This PR updates Fleet's reading of that
key for package verification to support that hashing algorithm change.

---------

Co-authored-by: Kibana Machine <[email protected]>
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 2, 2023
…ic#167149)

## Summary

Ref elastic/elasticsearch#85876
Fixes elastic#167153

The public Elastic GPG key has been updated to use sha256 instead of
sha1 for its hashing algorithm. This PR updates Fleet's reading of that
key for package verification to support that hashing algorithm change.

---------

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit b2a7b55)
kibanamachine referenced this issue in elastic/kibana Oct 3, 2023
…#167149) (#167823)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Fleet] Prefer sha256 for reading GPG package verification key
(#167149)](#167149)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kyle
Pollich","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-10-02T18:48:12Z","message":"[Fleet]
Prefer sha256 for reading GPG package verification key (#167149)\n\n##
Summary\n\nRef
https://github.com/elastic/elasticsearch/issues/85876\nFixes
https://github.com/elastic/kibana/issues/167153\n\nThe public Elastic
GPG key has been updated to use sha256 instead of\nsha1 for its hashing
algorithm. This PR updates Fleet's reading of that\nkey for package
verification to support that hashing algorithm
change.\n\n---------\n\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"b2a7b55f0e753656225a1c7215a08676a9c04819","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.11.0"],"number":167149,"url":"https://github.com/elastic/kibana/pull/167149","mergeCommit":{"message":"[Fleet]
Prefer sha256 for reading GPG package verification key (#167149)\n\n##
Summary\n\nRef
https://github.com/elastic/elasticsearch/issues/85876\nFixes
https://github.com/elastic/kibana/issues/167153\n\nThe public Elastic
GPG key has been updated to use sha256 instead of\nsha1 for its hashing
algorithm. This PR updates Fleet's reading of that\nkey for package
verification to support that hashing algorithm
change.\n\n---------\n\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"b2a7b55f0e753656225a1c7215a08676a9c04819"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/167149","number":167149,"mergeCommit":{"message":"[Fleet]
Prefer sha256 for reading GPG package verification key (#167149)\n\n##
Summary\n\nRef
https://github.com/elastic/elasticsearch/issues/85876\nFixes
https://github.com/elastic/kibana/issues/167153\n\nThe public Elastic
GPG key has been updated to use sha256 instead of\nsha1 for its hashing
algorithm. This PR updates Fleet's reading of that\nkey for package
verification to support that hashing algorithm
change.\n\n---------\n\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"b2a7b55f0e753656225a1c7215a08676a9c04819"}}]}]
BACKPORT-->

Co-authored-by: Kyle Pollich <[email protected]>
Co-authored-by: Julia Bardi <[email protected]>
@ghen2
Copy link

ghen2 commented Dec 11, 2023

If you still have the old key installed (and any package matching it), rpm will still complain about SHA-1 on every invocation. After installing the new key, you should explicitly remove the old one from the RPM db: rpm -e gpg-pubkey-d88e42b4-52371eca

rwxd added a commit to rwxd/beats that referenced this issue Jun 13, 2024
…tems

On newer RHEL systems SHA1 keys are no longer supported

related issue: 
elastic/elasticsearch#85876
Solution: 
elastic/elasticsearch#85876 (comment)
rwxd added a commit to rwxd/beats that referenced this issue Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >enhancement Team:Delivery Meta label for Delivery team
Projects
None yet
Development

No branches or pull requests