Skip to content

Commit

Permalink
Merge pull request #53 from adangel/gpg-configuration
Browse files Browse the repository at this point in the history
Rework gpg configuration
  • Loading branch information
jsotuyod authored Jan 3, 2025
2 parents d196626 + 40b4303 commit 3ff9c72
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 257 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ jobs:
shell: bash
env:
PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
PMD_CI_GPG_PRIVATE_KEY: ${{ secrets.PMD_CI_GPG_PRIVATE_KEY }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.PMD_CI_GPG_PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
152 changes: 89 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,15 @@ Used global vars:
* PMD_CI_SECRET_PASSPHRASE: This is provided as a github secret
(`PMD_CI_SECRET_PASSPHRASE: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}`) in github actions workflow.
It is used to decrypt further secrets used by other scripts (github releases api, ...)
* PMD_CI_GPG_PRIVATE_KEY: The exported private key used for release signing, provided as a secret
(`PMD_CI_GPG_PRIVATE_KEY: ${{ secrets.PMD_CI_GPG_PRIVATE_KEY }}`) in github actions workflow.

Test with:

```
bash -c 'set -e; \
export PMD_CI_SECRET_PASSPHRASE=.... ; \
export PMD_CI_GPG_PRIVATE_KEY=.... ; \
export PMD_CI_DEBUG=false ; \
source inc/setup-secrets.bash ; \
pmd_ci_setup_secrets_private_env ; \
Expand Down Expand Up @@ -456,12 +459,6 @@ export PMD_CI_SECRET_PASSPHRASE=...
export CI_DEPLOY_USERNAME=...
export CI_DEPLOY_PASSWORD=...
# CI_SIGN_KEYNAME - GPG key used to sign the release jars before uploading to maven central
# CI_SIGN_PASSPHRASE
# the passphrase is also used for the keystore password in pmd-eclipse-plugin for JAR signing.
export CI_SIGN_KEYNAME=...
export CI_SIGN_PASSPHRASE=...
export PMD_SF_USER=...
# https://sourceforge.net/p/forge/documentation/Using%20the%20Release%20API/
export PMD_SF_APIKEY=...
Expand All @@ -485,57 +482,6 @@ export GEM_HOST_API_KEY=...
export PMD_CI_CHUNK_TOKEN=...
```

### release-signing-key-D0BF1D737C9A1C22.asc

Export the private key as "release-signing-key-D0BF1D737C9A1C22" and encrypt it with PMD_CI_SECRET_PASSPHRASE:

```
printenv PMD_CI_SECRET_PASSPHRASE | gpg --symmetric --cipher-algo AES256 --batch --armor \
--passphrase-fd 0 \
release-signing-key-D0BF1D737C9A1C22
```

The public key is available here:
* <https://keys.openpgp.org/search?q=0xEBB241A545CB17C87FACB2EBD0BF1D737C9A1C22>
* <https://keyserver.ubuntu.com/pks/lookup?search=0xEBB241A545CB17C87FACB2EBD0BF1D737C9A1C22&fingerprint=on&op=index>
* <http://pgp.mit.edu/pks/lookup?search=0xD0BF1D737C9A1C22&fingerprint=on&op=index>

And in the file `release-signing-key-D0BF1D737C9A1C22-public.asc`.

**Updating the key:**

From time to time the key needs to be renewed. Import the private and public key into your local gpg keystore
and renew it. Make sure to renew all subkeys. Then export it again.

*Note:* The private key is additionally secured by a passphrase - see "CI_SIGN_PASSPHRASE".

You can verify the expiration date with `gpg --fingerprint --list-sigs D0BF1D737C9A1C22`:

```
pub rsa4096 2019-12-16 [SC] [expires: 2025-12-31]
EBB2 41A5 45CB 17C8 7FAC B2EB D0BF 1D73 7C9A 1C22
uid [ultimate] PMD Release Signing Key <[email protected]>
sig 3 D0BF1D737C9A1C22 2024-11-22 PMD Release Signing Key <[email protected]>
sig 3 93450DF2DF9A3FA3 2019-12-16 Andreas Dangel <[email protected]>
sig 3 D0BF1D737C9A1C22 2019-12-16 PMD Release Signing Key <[email protected]>
sig 3 D0BF1D737C9A1C22 2020-11-02 PMD Release Signing Key <[email protected]>
sub rsa4096 2019-12-16 [E] [expires: 2025-12-31]
sig D0BF1D737C9A1C22 2024-11-22 PMD Release Signing Key <[email protected]>
```

Upload the exported *public* key to

* <https://keys.openpgp.org/upload>
* <https://keyserver.ubuntu.com/#submitKey>
* <http://pgp.mit.edu/>

Verify the uploaded key expiration date:

`gpg --show-keys release-signing-key-D0BF1D737C9A1C22-public.asc`
`curl 'https://keys.openpgp.org/vks/v1/by-fingerprint/EBB241A545CB17C87FACB2EBD0BF1D737C9A1C22' | gpg --show-keys`
`curl 'https://keyserver.ubuntu.com/pks/lookup?search=0xEBB241A545CB17C87FACB2EBD0BF1D737C9A1C22&fingerprint=on&exact=on&options=mr&op=get' | gpg --show-keys`
`curl 'http://pgp.mit.edu/pks/lookup?op=get&search=0xD0BF1D737C9A1C22' | gpg --show-keys`

### pmd.github.io_deploy_key.asc

Created with `ssh-keygen -t ed25519 -C "ssh key for pmd. used for github actions to push to pmd.github.io" -f pmd.github.io_deploy_key`.
Expand Down Expand Up @@ -610,12 +556,8 @@ Note: The same key is used to push to "git.code.sf.net" as user "PMD_SF_USER".

### maven-settings.xml

The maven-settings.xml file contains a profile `sign`, which brings in the configuration for
`maven-gpg-plugin` to sign the artifacts prior to uploading it to maven central. The configuration
comes in via environment variables: `CI_SIGN_KEYNAME` and `CI_SIGN_PASSPHRASE`.

It also contains the credentials for uploading the artifacts to maven-central for the server `ossrh`. Again,
the actual configuration comes in via environment variables: `CI_DEPLOY_USERNAME` and `CI_DEPLOY_PASSWORD`.
It contains the credentials for uploading the artifacts to maven-central for the server `ossrh`.
The actual configuration comes in via environment variables: `CI_DEPLOY_USERNAME` and `CI_DEPLOY_PASSWORD`.

## Testing

Expand Down Expand Up @@ -671,6 +613,90 @@ you would need to manually publish the staging repo. See also the section below

## Miscellaneous

### Release Signing Keys

For signing the artifacts, that are published in Maven Central, we use GPG. The key fingerprint
is `EBB241A545CB17C87FACB2EBD0BF1D737C9A1C22`:

```
pub rsa4096/D0BF1D737C9A1C22 2019-12-16 [SC] [expires: 2025-12-31]
EBB241A545CB17C87FACB2EBD0BF1D737C9A1C22
uid [ultimate] PMD Release Signing Key <[email protected]>
sub rsa4096/1DAA314BF520D0A8 2019-12-16 [E] [expires: 2025-12-31]
```

The public key is available here:
* <https://keys.openpgp.org/search?q=0xEBB241A545CB17C87FACB2EBD0BF1D737C9A1C22>
* <https://keyserver.ubuntu.com/pks/lookup?search=0xEBB241A545CB17C87FACB2EBD0BF1D737C9A1C22&fingerprint=on&op=index>
* <http://pgp.mit.edu/pks/lookup?search=0xD0BF1D737C9A1C22&fingerprint=on&op=index>

And in the file `release-signing-key-D0BF1D737C9A1C22-public.asc`.

**Private key:**

The corresponding private key is configured as a [`secret`](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets)
for GitHub Action on the organization level. This means, the secret is available for all repositories.
The secret name is `PMD_CI_GPG_PRIVATE_KEY`.

For setting up, export the secret key and copy-paste it into a new secret:

```
gpg --armor --export-secret-key EBB241A545CB17C87FACB2EBD0BF1D737C9A1C22 | wl-copy
```

(instead of wl-copy, use xclip or pbcopy, depending on your os).

This private key will be imported by the script `setup-secrets.bash`.

Note 1: In order to use the key later on, the passphrase is needed. This is also setup as a secret:
`PMD_CI_GPG_PASSPHRASE`. This secret is then exported as "MAVEN_GPG_PASSPHRASE" where needed
(`MAVEN_GPG_PASSPHRASE: ${{ secrets.PMD_CI_GPG_PASSPHRASE }}`) in github actions workflows.
See also <https://maven.apache.org/plugins/maven-gpg-plugin/usage.html#sign-artifacts-with-gnupg>.


Note 2: The private key is now only secured by the passphrase. It is stored as a GitHub Actions
secret and temporarily written to a file in order to import it. It is not anymore committed in
this build-tools repository and is therefore not encrypted with another key (e.g. PMD_CI_SECRET_PASSPHRASE).

**Updating the key:**

From time to time the key needs to be renewed, passphrase needs to be changed or a whole key needs to
be replaced.

For renewing or changing the passphrase, import the private and public key into your local gpg keystore
and renew it. Make sure to renew all subkeys. Then export it again.

For replacing, generate a new key, just export it.

You can verify the expiration date with `gpg --fingerprint --list-sigs D0BF1D737C9A1C22`:

```
pub rsa4096 2019-12-16 [SC] [expires: 2025-12-31]
EBB2 41A5 45CB 17C8 7FAC B2EB D0BF 1D73 7C9A 1C22
uid [ultimate] PMD Release Signing Key <[email protected]>
sig 3 D0BF1D737C9A1C22 2024-11-22 PMD Release Signing Key <[email protected]>
sig 3 93450DF2DF9A3FA3 2019-12-16 Andreas Dangel <[email protected]>
sig 3 D0BF1D737C9A1C22 2019-12-16 PMD Release Signing Key <[email protected]>
sig 3 D0BF1D737C9A1C22 2020-11-02 PMD Release Signing Key <[email protected]>
sub rsa4096 2019-12-16 [E] [expires: 2025-12-31]
sig D0BF1D737C9A1C22 2024-11-22 PMD Release Signing Key <[email protected]>
```

Upload the exported *public* key to

* <https://keys.openpgp.org/upload>
* <https://keyserver.ubuntu.com/#submitKey>
* <http://pgp.mit.edu/>

Verify the uploaded key expiration date:

`gpg --show-keys release-signing-key-D0BF1D737C9A1C22-public.asc`
`curl 'https://keys.openpgp.org/vks/v1/by-fingerprint/EBB241A545CB17C87FACB2EBD0BF1D737C9A1C22' | gpg --show-keys`
`curl 'https://keyserver.ubuntu.com/pks/lookup?search=0xEBB241A545CB17C87FACB2EBD0BF1D737C9A1C22&fingerprint=on&exact=on&options=mr&op=get' | gpg --show-keys`
`curl 'http://pgp.mit.edu/pks/lookup?op=get&search=0xD0BF1D737C9A1C22' | gpg --show-keys`

Don't forget to update the secret `PMD_CI_GPG_PRIVATE_KEY` with the renewed private key.

### Nexus Staging Maven Plugin

See <https://github.com/sonatype/nexus-maven-plugins/tree/master/staging/maven-plugin>.
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.7</version>
<configuration>
<bestPractices>true</bestPractices>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down
10 changes: 1 addition & 9 deletions scripts/files/maven-settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@
</servers>
<mirrors/>
<proxies/>
<profiles>
<profile>
<id>sign</id>
<properties>
<gpg.keyname>${env.CI_SIGN_KEYNAME}</gpg.keyname>
<gpg.passphrase>${env.CI_SIGN_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
<profiles/>
<activeProfiles/>
</settings>
45 changes: 21 additions & 24 deletions scripts/files/private-env.asc
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
-----BEGIN PGP MESSAGE-----

jA0ECQMCgVuYgIIBDf3/0uoBmhLe1KXWqRzf//ULiAUtSM3IBBVWr7qAube7aocf
DWASvt8Fs9Au2Yy1FzjFvHGxdJ4H46m1IosMoZW5j9G86Q8Lik+1BkgeDh7yyw5u
AJy+8rqfw8hvDjSUJdyx1a1EB47d2DypIXZldeDy/0K8Q+E+CJAKyU2r3sErcT/P
2n/Q0HZfZQMugaRInCAAqqFkbmLWOAu16CDz7qy5uf/NjrvZPxRp/e2IDaVxDVJf
UHk+8dOW6IxinLXMRV8G37RUUl4n3ZFbzI1HLD4TVMMEpQeuY19vlgRWzrshzhfM
DskqWgIvhzOfKWhgbp0Y1GDBQCmOVcJTjv7EKsqr4HANqtOi9RmN/fWyloWizewA
nvkSjhNvKQ4mpqbzemwV4q1eQHXtrw8bT36cSBEMeWXPCHDayyO8CfbF4Zj3zFG6
iu0DUVZtxQMGHAGzIuG8v45MuYP6AKXlaJJz9JNNl1p3Tc7C2zvAv0yTTvdXWUC+
0zMgNju89cfQjBZnLDSblgwSlar/Cqw9Os4A9f4mFxqUUEnGFj2LuUPL4G1xfPIs
AiVvMkGZPRpFTlSk5jSop2Dw92SXhDjHhorYneSsUbLjZ9o6t9f2FTk8yHBCdjPQ
v8fEPY2Xf5TRP3XyIRqj8QB5TN8ZhThCQ5U/7ouJsqR7wOltKp6QQrM+h6jaKefI
VSolOgFsEiUIhrVPVNcSBRtlmf5JoXo4dGHXtZKUH7FwBzggcZGoIhFaSoqWnYwW
1J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