-
Notifications
You must be signed in to change notification settings - Fork 0
Improve GPG signing documentation security and modernize approach #11
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
Changes from all commits
cdfa82b
c902fc9
1051c15
ebc5819
a0c3395
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -32,20 +32,50 @@ gpg --list-keys --keyid-format SHORT | |||||
| # Upload your public key to a key server | ||||||
| gpg --keyserver keyserver.ubuntu.com --send-keys ABCD1234 | ||||||
|
|
||||||
| # Export your secret key ring (for Gradle signing) | ||||||
| gpg --export-secret-keys ABCD1234 > ~/.gnupg/secring.gpg | ||||||
| # Export your secret key ring (legacy approach for GPG < 2.1) | ||||||
| # WARNING: This creates a plaintext secret key file! | ||||||
| gpg --export-secret-keys -o ~/.gnupg/secring.gpg ABCD1234 | ||||||
| chmod 600 ~/.gnupg/secring.gpg # Set strict permissions | ||||||
| ``` | ||||||
|
|
||||||
| **Note:** The above method uses the legacy keyring format. Modern GPG (2.1+) doesn't use `secring.gpg` by default. See the recommended approach below. | ||||||
|
|
||||||
| ### 3. Configure Credentials | ||||||
|
|
||||||
| Add credentials to your `~/.gradle/gradle.properties` (NOT the project's `gradle.properties`): | ||||||
| #### Recommended: Modern In-Memory Signing (GPG 2.1+) | ||||||
|
|
||||||
| For modern GPG versions, use the in-memory signing approach with the `signingKey` property: | ||||||
|
|
||||||
| ```bash | ||||||
| # Export your private key in ASCII-armored format | ||||||
| gpg --armor --export-secret-keys ABCD1234 | ||||||
| ``` | ||||||
|
|
||||||
| Add to your `~/.gradle/gradle.properties` (NOT the project's `gradle.properties`): | ||||||
|
|
||||||
| ```properties | ||||||
| # Sonatype OSSRH credentials | ||||||
| sonatypeUsername=your-sonatype-username | ||||||
| sonatypePassword=your-sonatype-password | ||||||
|
|
||||||
| # GPG signing configuration | ||||||
| # GPG signing configuration (modern approach) | ||||||
| signing.keyId=ABCD1234 | ||||||
| signing.password=your-gpg-passphrase | ||||||
| signing.key=-----BEGIN PGP PRIVATE KEY BLOCK-----\n...(paste output from gpg --armor --export-secret-keys)...\n-----END PGP PRIVATE KEY BLOCK----- | ||||||
|
||||||
| signing.key=-----BEGIN PGP PRIVATE KEY BLOCK-----\n...(paste output from gpg --armor --export-secret-keys)...\n-----END PGP PRIVATE KEY BLOCK----- | |
| signing.key=-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: GnuPG v2\n\nmQINBF1EXAMPLEBEADAwEAAQ...\n...(multi-line base64 data from `gpg --armor --export-secret-keys ABCD1234` output, with each newline replaced by `\n`)...\n=ABCD\n-----END PGP PRIVATE KEY BLOCK----- |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning about creating a plaintext secret key file is helpful, but the same concern applies to the modern approach when storing in gradle.properties. Consider adding a note that when using the modern approach with signing.key in ~/.gradle/gradle.properties, users should also set strict permissions on that file (chmod 600) since it contains the private key in plaintext as well.
| **Note:** The `signing.key` value should be the entire ASCII-armored private key block from the `gpg --armor --export-secret-keys ABCD1234` command output. When storing as a single-line property, replace actual newlines with the literal string `\n`. | |
| **Note:** The `signing.key` value should be the entire ASCII-armored private key block from the `gpg --armor --export-secret-keys ABCD1234` command output. When storing as a single-line property, replace actual newlines with the literal string `\n`. The `~/.gradle/gradle.properties` file now contains your private key in plaintext, so ensure it has strict permissions (for example, run `chmod 600 ~/.gradle/gradle.properties`). |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially misleading security claim. The statement that the modern in-memory approach "doesn't require a plaintext key file on disk" is not entirely accurate. When the signing.key property is stored in ~/.gradle/gradle.properties, it is still a plaintext key file on disk - just in a different location. The main security advantage is that the key can be provided via environment variables in CI/CD without persisting to disk, which should be clarified.
| - The modern in-memory approach (`signing.key`) is preferred as it doesn't require a plaintext key file on disk | |
| - The modern in-memory approach (`signing.key`) is preferred because it supports providing the key via environment variables (so it does not need to be written to disk in CI/CD) and avoids the legacy keyring file; if you store `signing.key` in `~/.gradle/gradle.properties`, it is still a plaintext key in a file on disk |
Copilot
AI
Dec 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent secret variable naming. Line 102 uses $GPG_PRIVATE_KEY_SECRET as an example, but line 218 documents the GitHub Actions secret as GPG_SIGNING_KEY. For consistency and to avoid confusion, the example on line 102 should reference the same variable name used in the GitHub Actions section, or clearly indicate that users should replace this with their actual secret variable name.
| export ORG_GRADLE_PROJECT_signingKey="$GPG_PRIVATE_KEY_SECRET" | |
| export ORG_GRADLE_PROJECT_signingKey="$GPG_SIGNING_KEY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent property name reference. Line 47 mentions
signingKeyproperty, but line 64 usessigning.key(with dot notation). The correct Gradle property name issigning.key, so this reference should be updated to match the actual property name used in the configuration examples.