aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/README.md b/README.md
index 65cbe3a..86090bf 100644
--- a/README.md
+++ b/README.md
@@ -78,3 +78,50 @@ email or user accepted by GPG.
### Other settings
Check out the [autoplugin definition](src/main/scala/SbtGpg.scala) for
an exhaustive list of settings and tasks that can be customized.
+
+## Securely Publishing Locally
+
+Some projects use the "release from the maintainer's laptop" strategy. There's nothing *specifically* wrong with this strategy from a security standpoint, so long as the maintainer in question practices good security hygiene and protects their signing key appropriately (hint: *strongly* consider a YubiKey or similar if you maintain OSS projects; it's quite cheap and solves a major security vulnerability).
+
+This plugin is well-optimized for this publication strategy, and in fact it is the secure default! You don't need to do anything to publish using a local key. Simply invoke `publish` (as described above), securely unlock your key when prompted by `pinentry`, and all of the signing and key management will be handled for you.
+
+## Securely Publishing in Travis (and other CI)
+
+*Note: These instructions are written in terms of Travis, since it is probably the most common CI server in use today, but they are easily applicable to any which supports secure key management.*
+
+It is very common to configure your CI server (Travis or otherwise) to perform the artifact signing and publication tasks. Conventionally, builds generally rely upon GPG's key encryption functionality to apply a decryption password to the key. The (password-protected) signing key is then checked in with the source code while the decryption password is encrypted and managed by the CI server. At build-time, this password is decrypted and injected into the build using an environment variable, closing the loop and allowing the CI server to securely decrypt the signing key and publish the artifacts.
+
+This scheme works well when SBT manages signing key passwords and decryption (as in sbt-pgp). It works quite poorly when securely delegating to `pinentry`, as is the case with this plugin.
+
+The solution is to *not* password-protect the CI signing key and instead encrypt it explicitly using `openssl`. To start with, you should have your CI signing key in your local GPG keyring. Let's assume this key has a signature of `1234ABCD`. Run the following commands within your project root:
+
+```bash
+$ gpg --export-secret-keys -a 1234ABCD > key.asc
+$ travis encrypt_file key.asc --add
+$ rm key.asc
+$ git add key.asc.enc
+$ git commit
+```
+
+Replace `travis encrypt_file` with whatever mechanism is required to securely encrypt files for your CI solution. You may omit the `--add` switch and manually modify your `.travis.yml` if you prefer. Travis' file encryption documentation is [here](https://docs.travis-ci.com/user/encrypting-files/).
+
+These steps handle securely materializing a plain-text (*not* password protected!) secret key on your CI server. The only remaining task is to make it available to `gpg` on your CI so that it can be picked up by sbt-gpg. If using Travis, add the following to your `.travis.yml`:
+
+```yaml
+before_script: gpg --import key.asc
+```
+
+### Best Practices
+
+Do **NOT** use your personal GPG key for CI signing! Ever. Your personal private key should never leave your laptop. In fact, it probably shouldn't be on your laptop at all. Strongly consider YubiKey or similar. Never, *ever* enter the decryption password (or smartcard PIN) for your private key into anything other than `pinentry` on your local machine. If you're using MacGPG (which you should be, if using macOS), this dialog will look similar to the following:
+
+![macgpg-pinentry](https://i.imgur.com/ciol75g.png)
+
+If you are using your CI server to sign artifacts, your CI server should have *its own* public/private key pair, generated by you (or someone else on your team). You probably also want to sign that CI key with your own key, establishing a chain of trust (assuming the CI signing key has ID `1234AVCD`):
+
+```bash
+$ gpg --sign-key 1234ABCD
+$ gpg --send-key 1234ABCD
+```
+
+This is *not* the same as using your personal key for CI signing!