#!/bin/bash # Author: Daniel Kahn Gillmor # Date: 2010-12-20 20:54:55-0500 # On a system with keys for https (or some other X.509-using protocol) # already imported into monkeysphere-host, this script generates X.509 # certificate requests for each key, with appropriate subjectAltNames # and the PGPExtension embedded. # The generated requests get dumped to stdout. redirect to a file or # copy/paste if you want to save them/send them someplace. # This script uses bashisms # It currently needs OpenSSL binaries to work properly # It assumes that the monkeysphere-host keyring is in # /var/lib/monkeysphere/host (which it is on debian) # This should probably eventually be incorporated into # monkeysphere-host directly. get_openssl_config() { # first param is seconds since the epoch: X509_PGP_EXTENSION="$(TZ=UTC date -d "@$1" '+%Y%m%d%H%M%SZ')" # next parameter is SAN names, separated by newlines: SUBJECTALTNAME=$(printf "%s" "$2" | sed 's/^/DNS:/' | tr '\n' ',' | \ sed -e 's/,*$//' -e 's/^,*//') printf "sAN: %s\n" "$SUBJECTALTNAME" >&2 cat <