Skip to content

Commit 4e7ebf2

Browse files
committed
Add article about GPG-signed tags/commits
...in a GPG-signed commit
1 parent bf475a3 commit 4e7ebf2

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
layout: post
3+
title: "gpg-sign releases"
4+
category: advanced
5+
---
6+
7+
As a developer you use code written by other people _all the time_. To keep upstream changes from breaking your code, you depend on release numbers. Libraries like "bootstrap":https://github.com/twbs/bootstrap use "git tags":http://gitready.com/beginner/2009/02/03/tagging.html to track releases and make them available for download.
8+
9+
This strategy is common enough that GitHub has a handy release page right "here":https://github.com/twbs/bootstrap/releases/tag/v3.3.0 to download the zip/tar.gz of the tag you need.
10+
11+
You have the tarball, but are you sure you have the right code? Could the NSA have tampered with it? Could your internet service provider? Could GitHub? That release passes through many hands between the developer's hard drive and yours.
12+
13+
Well what if we cloned the repo directly? Commits are all hashed, and you can examine the history.
14+
15+
<pre>
16+
$ git clone --branch v3.3.0 https://github.com/twbs/bootstrap
17+
</pre>
18+
19+
Unfortunately, this very site can tell you how to "alter git history":http://localhost:4000/intermediate/2009/01/31/intro-to-rebase.html. Someone sneaky could hide a malicious change in the project history. Luckily, git can help. Signed tags use "Gnu Privacy Guard":https://www.gnupg.org/ to verify that a tag was made by the developers of the project, and that the contents are correct.
20+
21+
<pre>
22+
$ cd bootstrap
23+
$ git tag --verify v3.3.0
24+
error: 16dbdbd7a2c6cfa3be4e5dcc52249e577c02c84a: cannot verify a non-tag object of type commit.
25+
error: could not verify the tag 'v3.3.0'
26+
</pre>
27+
28+
Dang, doesn't look like bootstrap signs their tags. Let's try a project that does sign their tags.
29+
30+
<pre>
31+
$ git clone --branch v1.0.0 https://github.com/hudl/fargo
32+
$ git tag --verify v1.0.0
33+
object 5f63bca56a2f0268e5934655279dc8705fae4079
34+
type commit
35+
tag v1.0.0
36+
tagger Ryan S. Brown <[email protected]> 1403217530 -0500
37+
38+
Add DNS discovery for Eureka
39+
gpg: Signature made Thu 19 Jun 2014 06:41:01 PM EDT using RSA key ID 7907CCDB
40+
gpg: Good signature from "Ryan Scott Brown (ryansb) <[email protected]>"
41+
gpg: aka "Ryan Scott Brown (ryansb) <[email protected]>"
42+
</pre>
43+
44+
Neat, now you can see the key fingerprint it was signed with, check that the key is valid. Search "pgp.mit.edu":http://pgp.mit.edu/pks/lookup?search=ryansb%40csh.rit.edu&op=vindex for the email address and compare the key ID to confirm that it's signed by the right person.
45+
46+
*Note: Version "1.7.9":https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/1.7.9.txt introduced the ability to sign commits as well as tags.*
47+
48+
To sign tags on your own project, you'll need a GPG key of your own. Head over to "this tutorial":http://www.dewinter.com/gnupg_howto/english/GPGMiniHowto-3.html#ss3.1 to get set up if you don't already have a key. If you have multiple keys, you need to configure your signing key.
49+
50+
<pre>
51+
git config --global user.signingkey [email protected]
52+
</pre>
53+
54+
Now you can make a release as normal, but with a signed commit.
55+
56+
<pre>
57+
git tag -s v0.1 -m "the best version yet"
58+
</pre>
59+
60+
The only difference here is the @-s@. Before you upload the tag be sure to check your signature with @git tag --verify v0.1@.
61+
62+
If your project has multiple developers there are a few ways to handle signing releases. The project can have a release-signing key with subkeys for each developer, or developers can use their personal key. Both of these work, but document which method you choose. Users need to know what to expect when they check the release signature.
63+
64+
Just signing releases is a great start, but they aren't any good if your users don't check them. Make sure to put a note in your @README@ that you sign releases, and where to find the public key your project uses.

0 commit comments

Comments
 (0)