2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere host revoke-key subcommand
6 # The monkeysphere scripts are written by:
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 # They are Copyright 2008-2009, and are all released under the GPL,
18 # Coming in here, we expect $HOST_FINGERPRINT to be set, and we
19 # believe that there is in fact a key.
21 if [ "$PROMPT" = "false" ] ; then
25 This will generate a revocation certificate for your host key
26 (fingerprint: $HOST_FINGERPRINT) and
27 dump the certificate to standard output.
29 It can also directly publish the new revocation certificate
30 to the public keyservers via $KEYSERVER if you want it to.
32 Publishing this certificate will IMMEDIATELY and PERMANENTLY revoke
36 read -p "Publish the certificate after generation? (y/n/Q) " publish
38 if ! [ "${publish/y/Y}" = 'Y' -o "${publish/n/N}" = 'N' ] ; then
39 failure "aborting at user request"
43 # our current implementation is very simple: we just want to
44 # generate the revocation certificate on stdout. This provides
45 # for the two most likely (but hopefully not common) scenarios:
47 # an admin wants a revocation certificate for the host which they
48 # can store securely offline. In this case, the admin can
49 # redirect stdout to a file, or can simply copy/paste or
50 # transcribe from the terminal.
52 # Alternately, an admin might want to publish the revocation
53 # certificate immediately, which we can help them do as well.
55 if [ "$PROMPT" = 'false' ] ; then
56 local revoke_commands="y
58 Monkeysphere host key revocation (no prompting) $(date '+%F_%T')
63 revcert=$(GNUPGHOME="$GNUPGHOME_HOST" gpg_host --command-fd 0 --armor --gen-revoke "0x${HOST_FINGERPRINT}!" <<<"$revoke_commands" ) \
64 || failure "Failed to generate revocation certificate!"
68 # note: we're not using the gpg_host function because we actually
69 # want to use gpg's UI in this case, so we want to omit --no-tty
70 revcert=$(GNUPGHOME="$GNUPGHOME_HOST" gpg --no-greeting --quiet --armor --gen-revoke "0x${HOST_FINGERPRINT}!") \
71 || failure "Failed to generate revocation certificate!"
74 # if you run gpg --gen-revoke but cancel it or quit in the middle,
75 # it returns success, but emits no revocation certificate:
76 if ! [ "$revcert" ] ; then
77 failure "Revocation canceled."
80 ## ok, now we have the revocation certificate. Print it, and
81 ## offer to publish if originally requested:
82 printf "%s\n" "$revcert"
84 if [ "${publish/y/Y}" = 'Y' ] ; then
86 read -p "Really publish this cert to $KEYSERVER ? (Y/n) " really
87 if [ "${really/n/N}" = 'N' ] ; then
88 printf "Not publishing.\n" >&2
90 local newhome=$(mkmstempdir)
91 GNUPGHOME="$newhome" gpg --no-tty --quiet --import < "$HOST_KEY_FILE"
92 GNUPGHOME="$newhome" gpg --no-tty --quiet --import <<< "$revcert"
93 GNUPGHOME="$newhome" gpg --keyserver "$KEYSERVER" --send "0x${HOST_FINGERPRINT}!"