4 CONF="${2:-danet_client.conf}"
11 CLIENT_CERT=$(awk '/^cert /{print $2}' "$CONF");
12 CLIENT_KEY=$(awk '/^key /{print $2}' "$CONF");
13 SERVER_CACERT=$(awk '/^ca /{print $2}' "$CONF");
17 cat -<<EOF |openssl req -nodes -new -keyout "${TMPDIR}/${HOST}".pem -out "${TMPDIR}/${HOST}".req -days 9000
32 if [ ! -e database ]; then
33 touch database database.attr
34 cp /usr/lib/ssl/openssl.cnf config
35 perl -pi -e 's/(database|serial)\s*=.+/$1=$1/' config
36 # Use the epoch and the pid to make a unique serial (for this CA,
38 # We use perl's pack and unpack here because it can be hex, and
39 # for some cockamamie reason, it needs to be an even number of
41 perl -e 'print unpack(q(H*),pack(q(NN),time,$$)),qq(\n)' > serial
43 openssl ca -config "$TMPDIR"/config -policy policy_anything -keyfile "${ORIGDIR}"/"${CAKEY}" -cert "${ORIGDIR}"/"${CACERT}" \
44 -out "$TMPDIR"/"${HOST}".cert -outdir "$TMPDIR" -notext -days $(( ( $(date -d 'Tuesday, 18 January 2038' +%s) - $(date +%s) ) / 60 / 60 /24 )) -batch -infiles "${HOST}".req; #> /dev/null 2>&1
45 chmod a+r "${HOST}".cert
47 mv "${HOST}".cert "${CLIENT_CERT}"
48 mv "${HOST}".pem "${CLIENT_KEY}"
51 cp "${CONF}" "${TMPDIR}"/;
52 cp "${SERVER_CACERT}" "${TMPDIR}"/;
54 tar -zcf "${HOST}".tar.gz -C "${TMPDIR}" \
55 "${CLIENT_CERT}" "${CONF}" \
56 "${CLIENT_KEY}" "${SERVER_CACERT}"
59 cp ../ccd/__template__ ../ccd/"${HOST}";
60 chmod 0644 ../ccd/"${HOST}";
61 HOST="${HOST}" perl -pi -e 's/HOSTNAME/$ENV{HOST}/g' ../ccd/"${HOST}";