From e50da193be297bc7a49c3be88a26586fa69bde51 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Sun, 2 Jan 2011 17:11:39 -0500 Subject: genericized x509 certificate generation -- now works for any service, not just https (invoke it like "make-x509-certreqs imap" for imap:// keys, etc) --- examples/make-x509-certreqs | 97 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 examples/make-x509-certreqs (limited to 'examples/make-x509-certreqs') diff --git a/examples/make-x509-certreqs b/examples/make-x509-certreqs new file mode 100644 index 0000000..6ff82a0 --- /dev/null +++ b/examples/make-x509-certreqs @@ -0,0 +1,97 @@ +#!/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 <