|
| 1 | +# New PGP keys |
| 2 | + |
| 3 | +**Guardian developers:** [further docs here](https://docs.google.com/document/d/1zA8CHa1a8faemorWokUlbkdexYzpilalqcPFwkRu92M/edit?tab=t.0#heading=h.mnrh0k50nysb). |
| 4 | + |
| 5 | +There are 4 steps to performing a credential rotation on the PGP key used by `gha-scala-library-release-workflow`: |
| 6 | + |
| 7 | +## Generate new PGP keypair |
| 8 | + |
| 9 | +The keypair should have a [**passphrase-less** private key](https://unix.stackexchange.com/a/550538/46453) - |
| 10 | +if you're generating the keypair, you can just enter blank passphrases. |
| 11 | + |
| 12 | +```bash |
| 13 | +gpg --quick-generate-key "Example Automated Maven Release <[email protected]>" |
| 14 | +``` |
| 15 | + |
| 16 | +This will give a new key id, eg like `EF53C0E05A7067985C09F1B2AAE7330D94C67345`. |
| 17 | + |
| 18 | +## Publish Public PGP key |
| 19 | + |
| 20 | +Maven Central _requires_ that the public PGP key is published to public keyservers - it will |
| 21 | +[_reject_](https://github.com/guardian/redirect-resolver/actions/runs/12158544330/job/33906914072#step:5:63) |
| 22 | +artifacts that are signed with unknown PGP keys: |
| 23 | + |
| 24 | +> Failed: signature-staging, failureMessage:No public key: Key with id: (aae7330d94c67345) was not able to be located on <a href="http://pgp.mit.edu:11371/">http://pgp.mit.edu:11371/</a>. Upload your public key and try the operation again. |
| 25 | +
|
| 26 | +The [official instructions](https://central.sonatype.org/publish/requirements/gpg/#distributing-your-public-key) |
| 27 | +say to use `gpg --keyserver` to publish the key, but unfortunately this gives |
| 28 | +`gpg: keyserver send failed: Network is unreachable` errors - so instead we have to |
| 29 | +manually paste our key into a web form on a PGP keyserver website. |
| 30 | + |
| 31 | +Execute this command to get the new public key copied into your copy-n-paste: |
| 32 | + |
| 33 | +```bash |
| 34 | +gpg --armor --export [insert key fingerprint here] | pbcopy |
| 35 | +``` |
| 36 | + |
| 37 | +_N.B. The above command uses `--export`, not `--export-secret-key` - we do **not** want |
| 38 | +to publicly share our private key._ |
| 39 | + |
| 40 | +You can use either (or both) of these keyservers: |
| 41 | + |
| 42 | +* https://keyserver.ubuntu.com/#submitKey - this _feels_ kind of more stable, and search works |
| 43 | +* https://pgp.mit.edu/ - Maven Central seems to be checking keys with this keyserver |
| 44 | + |
| 45 | +PGP keyservers are supposed to synchronise with each other, so wherever you publish the |
| 46 | +key it should eventually make it to the keyserver that Maven Central is checking with - but |
| 47 | +for the time being, publishing to `pgp.mit.edu` may get the key available sooner. |
| 48 | + |
| 49 | +## Store Private PGP key in a GitHub secret |
| 50 | + |
| 51 | +Execute this command to get the private key copied into your copy-n-paste: |
| 52 | + |
| 53 | +``` |
| 54 | +gpg --armor --export-secret-key [insert key fingerprint here] | pbcopy |
| 55 | +``` |
| 56 | + |
| 57 | +This can then be pasted into a GitHub secret. |
| 58 | + |
| 59 | +**Guardian developers:** We use the organisation-level GitHub secret |
| 60 | +[`AUTOMATED_MAVEN_RELEASE_PGP_SECRET`](https://github.com/organizations/guardian/settings/secrets/actions/AUTOMATED_MAVEN_RELEASE_PGP_SECRET) - |
| 61 | +as it's organisation-level, only an owner of our GitHub organisation can access it. |
| 62 | + |
| 63 | +## Destroy or secure your local copy of the PGP key |
| 64 | + |
| 65 | +As the private key had to be made **passphrase-less**, it is now vulnerable, and |
| 66 | +should be deleted or [edited](https://stackoverflow.com/q/77716552/438886) to add a passphrase. |
0 commit comments