Skip to content

Commit 7be8e84

Browse files
authored
Merge pull request #48 from guardian/add-docs-on-rotating-the-pgp-keypair
Add docs on using a new PGP keypair
2 parents b555f10 + 0605764 commit 7be8e84

File tree

2 files changed

+67
-10
lines changed

2 files changed

+67
-10
lines changed

docs/credentials/generating-credentials.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ Note these points:
2121

2222
## Generating a new PGP key
2323

24-
See [Sonatype's instructions](https://central.sonatype.org/publish/requirements/gpg/#generating-a-key-pair) for
25-
generating a keypair - ensure you upload the public key to a [keyserver](https://keyserver.ubuntu.com/).
26-
27-
However, note that `gha-scala-library-release-workflow` requires a
28-
[**passphrase-less** private key](https://unix.stackexchange.com/a/550538/46453), and that key
29-
should be plaintext, not BASE64-encoded.
30-
31-
```shell
32-
gpg --armor --export-secret-key [insert key fingerprint here] | pbcopy
33-
```
24+
See the full docs on [using a new PGP key](pgp-keys.md).
3425

3526
## Generating a new GitHub App private key
3627

docs/credentials/pgp-keys.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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

Comments
 (0)