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-2010, and are all released under the GPL,
21 keyID=$(check_key_input "$@")
23 if [ "$PROMPT" = "false" ] ; then
27 This will generate a revocation certificate for key $keyID
28 and dump the certificate to standard output.
30 It can also directly publish the new revocation certificate
31 to the public keyservers via $KEYSERVER if you want it to.
33 Publishing this certificate will IMMEDIATELY and PERMANENTLY revoke
37 printf "Publish the certificate after generation? (y/n/Q) " >&2
40 if ! [ "${publish/y/Y}" = 'Y' -o "${publish/n/N}" = 'N' ] ; then
41 failure "aborting at user request"
45 # our current implementation is very simple: we just want to
46 # generate the revocation certificate on stdout. This provides
47 # for the two most likely (but hopefully not common) scenarios:
49 # an admin wants a revocation certificate for the host which they
50 # can store securely offline. In this case, the admin can
51 # redirect stdout to a file, or can simply copy/paste or
52 # transcribe from the terminal.
54 # Alternately, an admin might want to publish the revocation
55 # certificate immediately, which we can help them do as well.
57 if [ "$PROMPT" = 'false' ] ; then
58 # FIXME: allow the end user to choose something other than
59 # "key was compromised" (1) and to supply their own revocation
62 local revoke_commands="y
64 Monkeysphere host key revocation (automated) $(date '+%F_%T%z')
69 revcert=$(GNUPGHOME="$GNUPGHOME_HOST" gpg_host --command-fd 0 --armor --gen-revoke "0x${keyID}!" <<<"$revoke_commands" ) \
70 || failure "Failed to generate revocation certificate!"
73 # note: we're not using the gpg_host function because we actually
74 # want to use gpg's UI in this case, so we want to omit --no-tty
75 revcert=$(GNUPGHOME="$GNUPGHOME_HOST" gpg --no-greeting --quiet --armor --gen-revoke "0x${keyID}!") \
76 || failure "Failed to generate revocation certificate!"
79 # if you run gpg --gen-revoke but cancel it or quit in the middle,
80 # it returns success, but emits no revocation certificate:
81 if ! [ "$revcert" ] ; then
82 failure "Revocation canceled."
85 ## ok, now we have the revocation certificate. Print it, and
86 ## offer to publish if originally requested:
87 printf "%s\n" "$revcert"
89 if [ "${publish/y/Y}" = 'Y' ] ; then
91 printf "Really publish this cert to $KEYSERVER ? (Y/n) " >&2
93 if [ "${really/n/N}" = 'N' ] ; then
94 printf "Not publishing.\n" >&2
96 local newhome=$(mkmstempdir)
97 GNUPGHOME="$newhome" gpg --no-tty --quiet --import < "$HOST_KEY_FILE"
98 GNUPGHOME="$newhome" gpg --no-tty --quiet --import <<< "$revcert"
99 GNUPGHOME="$newhome" gpg --keyserver "$KEYSERVER" --send "0x${HOST_FINGERPRINT}!"