Skip to content

CI: add pgp keys expiry check #10112

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

Merged

Conversation

GustavoStingelin
Copy link
Contributor

@GustavoStingelin GustavoStingelin commented Jul 28, 2025

Description

Closes #6281. This PR adds a new job to the CI pipeline that verifies the expiration of PGP keys. The job will fail if no valid signing-capable primary or subkey is found.

And, since we have some expired keys, the job is currently failing.

How to Test

Run the script manually:

bash scripts/check-pgp-expiry.sh

Or simulate the CI job locally using:

act -j pgp-key-expiration-check

To inspect the expiration dates for debugging, use:

gpg --with-colons --import-options show-only --import "$key_file"

Output:

➜  lnd git:(check-pgp-keys-expiry) scripts/check-pgp-expiry.sh

Starting PGP key validation...
Found 14 key file(s) in ./scripts/keys

────────────────────────────────────────────────────────────────────
Checking bhandras.asc...
INFO: pub:80E5375C094198D8 (scESC) is valid until 2027-06-06
────────────────────────────────────────────────────────────────────
Checking carlaKC.asc...
INFO: pub:4CA7FE54A6213C91 (scESC) is valid until 2034-05-05
────────────────────────────────────────────────────────────────────
Checking ellemouton.asc...
INFO: pub:D7D916376026F177 (scSC) is valid until 2026-06-21
────────────────────────────────────────────────────────────────────
Checking ffranr.asc...
WARN: pub:B1F8848557AA29D2 (sc) has already expired (2024-10-05)
ERROR: pub:B1F8848557AA29D2 (sc) primary key is invalid
ERROR: ffranr.asc does not have any valid sign key
────────────────────────────────────────────────────────────────────
Checking guggero.asc...
INFO: pub:8E4256593F177720 (scESC) is valid until 2034-04-28
────────────────────────────────────────────────────────────────────
Checking hieblmi.asc...
WARN: pub:F82D456EA023C9BF (sc) has already expired (2024-06-01)
ERROR: pub:F82D456EA023C9BF (sc) primary key is invalid
ERROR: hieblmi.asc does not have any valid sign key
────────────────────────────────────────────────────────────────────
Checking positiveblue.asc...
INFO: pub:E9FE7FE00AD163A4 (cC) does not expire
WARN: sub:4FFF2510928804DC (s) has already expired (2022-09-23)
ERROR: positiveblue.asc does not have any valid sign key
────────────────────────────────────────────────────────────────────
Checking proofofkeags.asc...
INFO: pub:FA7E65C951F12439 (scESC) is valid until 2027-05-28
────────────────────────────────────────────────────────────────────
Checking roasbeef.asc...
INFO: pub:DC42612E89237182 (scESCA) does not expire
────────────────────────────────────────────────────────────────────
Checking sputn1ck.asc...
WARN: pub:671103D881A5F0E4 (sc) has already expired (2024-01-05)
ERROR: pub:671103D881A5F0E4 (sc) primary key is invalid
ERROR: sputn1ck.asc does not have any valid sign key
────────────────────────────────────────────────────────────────────
Checking suheb.asc...
INFO: pub:00C9E2BC2E45666F (scESC) is valid until 2025-10-01
────────────────────────────────────────────────────────────────────
Checking ViktorTigerstrom.asc...
WARN: pub:B984570980684DCC (sc) has already expired (2025-06-05)
ERROR: pub:B984570980684DCC (sc) primary key is invalid
ERROR: ViktorTigerstrom.asc does not have any valid sign key
────────────────────────────────────────────────────────────────────
Checking yyforyongyu.asc...
INFO: pub:9BCD95C4FF296868 (scESC) is valid until 2036-07-14
────────────────────────────────────────────────────────────────────
Checking ziggie1984.asc...
INFO: pub:1AFF9C4DCED6D666 (scESC) is valid until 2025-11-30
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ERROR: Some PGP keys have issues that need attention.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @GustavoStingelin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've introduced a new CI job to proactively monitor the expiration dates of PGP keys. This job will ensure that any PGP keys (both primary and subkeys) located in the scripts/keys directory are checked, and the CI pipeline will fail if any key is set to expire within the next two weeks, helping to prevent unexpected service disruptions due to expired keys.

Highlights

  • New CI Job for PGP Key Expiry: I've added a new job to the CI pipeline specifically designed to check the expiration status of PGP keys. This job will run automatically to ensure key validity.
  • PGP Key Expiry Script: I've implemented a new shell script, scripts/check-pgp-expiry.sh, which is responsible for scanning PGP keys and identifying those that are nearing their expiration date.
  • Two-Week Expiry Threshold: The script is configured to flag any PGP key that is set to expire within the next two weeks, providing an early warning system for key management.
  • Error Handling and Reporting: The script includes robust error handling for missing key directories or invalid key files, and it will cause the CI job to fail if expiring keys are found or if it encounters issues parsing key information.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new shell script to check for PGP key expiration, which is a valuable addition to the CI pipeline. The script is well-structured and uses good practices like set -euo pipefail. My review includes a couple of suggestions to improve the script's robustness and code style, such as using a safer method for file globbing and optimizing the placement of a helper function. Overall, this is a great contribution.

@GustavoStingelin GustavoStingelin force-pushed the check-pgp-keys-expiry branch 2 times, most recently from 49e8fd9 to 5737c33 Compare July 28, 2025 02:46
Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature, thank you!

Left some comments.

@ziggie1984
Copy link
Collaborator

ziggie1984 commented Jul 29, 2025

something is off with the comparison see the results of the key expiration test, why does it say expires soon if the keys are already expired ? Moreover I wonder if one subkey is expired that we should fail the verification if another subkey for encryption is still valid ?

ERROR: guggero.asc sub fpr:C25F3295638298E3AFEBE70B48F5EB2E7E59AF8C expires soon (2023-04-24)
ERROR: guggero.asc sub fpr:B14D3C5CA570F03C911E04A6F0A0ED07755FDBCF expires soon (2023-05-12)
ERROR: guggero.asc sub fpr:E6DF8502529F86B491C65E1E988BB7626335E3FB expires soon (2023-05-12)
ERROR: guggero.asc sub fpr:FDE04B7075113BFB085020B57BBD8D4D95DB9F03 expires soon (2023-05-12)
ERROR: hieblmi.asc pub fpr:32F7EA1E7A0339F7D37164B9F82D456EA023C9BF expires soon (2024-06-01)
ERROR: hieblmi.asc sub fpr:BE0361F289337606273DF36BD93288D97E0EFF86 expires soon (2024-06-01)

@guggero
Copy link
Collaborator

guggero commented Jul 29, 2025

something is off with the comparison see the results of the key expiration test, why does it say expires soon if the keys are already expired ? Moreover I wonder if one subkey is expired that we should fail the verification if another subkey for encryption is still valid ?

ERROR: guggero.asc sub fpr:C25F3295638298E3AFEBE70B48F5EB2E7E59AF8C expires soon (2023-04-24)
ERROR: guggero.asc sub fpr:B14D3C5CA570F03C911E04A6F0A0ED07755FDBCF expires soon (2023-05-12)
ERROR: guggero.asc sub fpr:E6DF8502529F86B491C65E1E988BB7626335E3FB expires soon (2023-05-12)
ERROR: guggero.asc sub fpr:FDE04B7075113BFB085020B57BBD8D4D95DB9F03 expires soon (2023-05-12)
ERROR: hieblmi.asc pub fpr:32F7EA1E7A0339F7D37164B9F82D456EA023C9BF expires soon (2024-06-01)
ERROR: hieblmi.asc sub fpr:BE0361F289337606273DF36BD93288D97E0EFF86 expires soon (2024-06-01)

Yeah, wanted to say the same. I use sub keys so I can rotate them more easily. So only if all sub keys are expired should the script error out.

@GustavoStingelin
Copy link
Contributor Author

why does it say expires soon if the keys are already expired ?

It's just to simplify the logic, but I can implement a better xp

@GustavoStingelin
Copy link
Contributor Author

I wonder if one subkey is expired that we should fail the verification if another subkey for encryption is still valid ?

I use sub keys so I can rotate them more easily. So only if all sub keys are expired should the script error out.

Yeah, I was thinking about this while writing the script. I’ll implement that behavior since keeping old subkeys in the key file is more practical and avoids breaking the verification of past signatures.

@GustavoStingelin
Copy link
Contributor Author

Script Improvements

  • Simplified fingerprint extraction by using only the key ID (last 8 hex digits of the fingerprint). This avoids the need to parse two consecutive lines.
  • Added logic to ignore keys that are not capable of signing.
  • Changed validation logic to consider a key valid if at least one signing-capable pub/sub key is still valid.
    • Note: This introduces a trade-off. It no longer enforces the validity of signing subkeys, and some keys currently rely solely on the primary key for signing.

@ziggie1984
Copy link
Collaborator

ziggie1984 commented Jul 30, 2025

@guggero I wonder how we should handle keys of contributors who already left ? Their signature and the keys are still verifiable and valid if the signature was made when the key was valid ? Should we keep them around forever ?

Moreover people might already have an updated Pubkey on their local computer in if they sign it with it, it could be still verifiable with the pubkey which is in this repo but expired ?

fi

valid_sign_key_found=true
echo "INFO: $key_info is valid until $expiry_date"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we print the fingerprint anymore ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To print the full fingerprint, we need to parse two lines per key, which adds complexity to the script. I chose to stick with a single-line parse and print only the key ID instead.

The trade-off here is simplicity versus completeness, but since the ID is part of the fingerprint, in practice, we’re showing a shortened version of it. IMO it's not worth the extra parsing complexity just to print the full fingerprint here.

@guggero
Copy link
Collaborator

guggero commented Jul 30, 2025

@guggero I wonder how we should handle keys of contributors who already left ? Their signature and the keys are still verifiable and valid if the signature was made when the key was valid ? Should we keep them around forever ?

Moreover people might already have an updated Pubkey on their local computer in if they sign it with it, it could be still verifiable with the pubkey which is in this repo but expired ?

Hmm, good question. Don't really have a good answer or strong opinion.
I slightly lean toward removing keys from inactive signers. If necessary, old signatures can still be verified by pulling those keys from a key server.

@GustavoStingelin
Copy link
Contributor Author

If necessary, old signatures can still be verified by pulling those keys from a key server.

Also, older releases will retain their expired keys since they were previously committed along with the tag.

@ziggie1984
Copy link
Collaborator

I think however we need to also fail if the primary key expired, because for every verification the primary key is used the make sure the subkey was issued by it. So we need to make sure the primary key is not expired.

@GustavoStingelin
Copy link
Contributor Author

I think however we need to also fail if the primary key expired, because for every verification the primary key is used the make sure the subkey was issued by it. So we need to make sure the primary key is not expired.

ok, I've added this check.

Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good code wise, I would appreciate a more readable output of the script something like this (run it through my AI helper because currently the output is not super convenient to parse by a human:

--------------------------------------------------
Checking key file: ./scripts/keys/ViktorTigerstrom.asc
--------------------------------------------------
ERROR: ViktorTigerstrom.asc primary-key pub:B984570980684DCC (sc) has already expired (2025-06-05)
ERROR: ViktorTigerstrom.asc: primary key is invalid, skipping subkey check.
--------------------------------------------------
Checking key file: ./scripts/keys/bhandras.asc
--------------------------------------------------
INFO: bhandras.asc primary-key pub:80E5375C094198D8 (scESC) is valid until 2027-06-06
INFO: bhandras.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/carlaKC.asc
--------------------------------------------------
INFO: carlaKC.asc primary-key pub:4CA7FE54A6213C91 (scESC) is valid until 2034-05-05
INFO: carlaKC.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/ellemouton.asc
--------------------------------------------------
INFO: ellemouton.asc primary-key pub:D7D916376026F177 (scSC) is valid until 2026-06-21
INFO: ellemouton.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/ffranr.asc
--------------------------------------------------
ERROR: ffranr.asc primary-key pub:B1F8848557AA29D2 (sc) has already expired (2024-10-05)
ERROR: ffranr.asc: primary key is invalid, skipping subkey check.
--------------------------------------------------
Checking key file: ./scripts/keys/guggero.asc
--------------------------------------------------
INFO: guggero.asc primary-key pub:8E4256593F177720 (scESC) is valid until 2034-04-28
INFO: guggero.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/hieblmi.asc
--------------------------------------------------
ERROR: hieblmi.asc primary-key pub:F82D456EA023C9BF (sc) has already expired (2024-06-01)
ERROR: hieblmi.asc: primary key is invalid, skipping subkey check.
--------------------------------------------------
Checking key file: ./scripts/keys/positiveblue.asc
--------------------------------------------------
INFO: positiveblue.asc primary-key pub:E9FE7FE00AD163A4 (cC) does not expire
INFO: positiveblue.asc: primary key is not a signing key, checking subkeys
ERROR: positiveblue.asc sub:4FFF2510928804DC (s) has already expired (2022-09-23)
ERROR: positiveblue.asc does not have any valid signing key
--------------------------------------------------
Checking key file: ./scripts/keys/proofofkeags.asc
--------------------------------------------------
INFO: proofofkeags.asc primary-key pub:FA7E65C951F12439 (scESC) is valid until 2027-05-29
INFO: proofofkeags.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/roasbeef.asc
--------------------------------------------------
INFO: roasbeef.asc primary-key pub:DC42612E89237182 (scESCA) does not expire
INFO: roasbeef.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/sputn1ck.asc
--------------------------------------------------
ERROR: sputn1ck.asc primary-key pub:671103D881A5F0E4 (sc) has already expired (2024-01-05)
ERROR: sputn1ck.asc: primary key is invalid, skipping subkey check.
--------------------------------------------------
Checking key file: ./scripts/keys/suheb.asc
--------------------------------------------------
INFO: suheb.asc primary-key pub:00C9E2BC2E45666F (scESC) is valid until 2025-10-02
INFO: suheb.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/yyforyongyu.asc
--------------------------------------------------
INFO: yyforyongyu.asc primary-key pub:9BCD95C4FF296868 (scESC) is valid until 2036-07-14
INFO: yyforyongyu.asc has a valid primary signing key
--------------------------------------------------
Checking key file: ./scripts/keys/ziggie1984.asc
--------------------------------------------------
INFO: ziggie1984.asc primary-key pub:1AFF9C4DCED6D666 (scESC) is valid until 2025-11-30
INFO: ziggie1984.asc has a valid primary signing key
--------------------------------------------------
ERROR: PGP key validation failed. Please check the logs.

@GustavoStingelin
Copy link
Contributor Author

Looking good code wise, I would appreciate a more readable output of the script something like this (run it through my AI helper because currently the output is not super convenient to parse by a human:

Ok, take a look at this version that I pushed

Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@lightninglabs-deploy
Copy link

@GustavoStingelin, remember to re-request review from reviewers when ready

########################
# Check release signing keys
########################
pgp-key-expiration-check:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels more like a job that should be done in release.yaml than being checked for every PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also it looks like the job failed, maybe missing a rebase?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good idea to only run it for releases !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased here, but still have one invalid

Checking ViktorTigerstrom.asc...
WARN: pub:B984570980684DCC (sc) has already expired (2025-06-05)
ERROR: pub:B984570980684DCC (sc) primary key is invalid
ERROR: ViktorTigerstrom.asc does not have any valid sign key

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yyforyongyu I moved this to the release workflow, please check if everything is correct. Using act -j pgp-key-expiration-check works on my side.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we need to fix that invalid key @ViktorTigerstrom

Copy link
Member

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR🙏

@yyforyongyu yyforyongyu merged commit 3841d55 into lightningnetwork:master Aug 15, 2025
35 of 39 checks passed
@guggero
Copy link
Collaborator

guggero commented Aug 15, 2025

I don't think it's a good idea to fail a release because of an expired key! At that point we've pushed a tag and fixing it would mean create a new PR to remove the key, then push another tag. So IMO we should keep the step in the release pipeline but make sure we continue with the release build even on failure.
Or move it to a daily job, same as we do with the nightly build. There a failure would alert via email and potentially be picked up quicker.

@yyforyongyu
Copy link
Member

So IMO we should keep the step in the release pipeline but make sure we continue with the release build even on failure.
Or move it to a daily job, same as we do with the nightly build.

Yeah make sense - think we can either skip the error in the release build or move it to the daily job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI: create GitHub Action to detect soon to expire release signing PGP keys
5 participants