-
Notifications
You must be signed in to change notification settings - Fork 3
/
dcvfile.sh
26 lines (22 loc) · 1.14 KB
/
dcvfile.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# +----+----+----+----+
# | | | | |
# Author: Mark David Scott Cunningham | M | D | S | C |
# +----+----+----+----+
# Created: 2014-10-16
# Updated: 2014-12-15
#
#
#!/bin/bash
# Create DCV txt file for domain validation when ordering an SSL
# https://redkestrel.co.uk/articles/openssl-commands/ << OMG! OMG! OMG!
# https://redkestrel.co.uk/articles/openssl-commands/#convert-cert << Convert the PEM-CSR to a DER-CSR
# https://redkestrel.co.uk/articles/openssl-commands/#fingerprint << Find the MD5/SHA1 fingerprints of the DER-CSR
if [[ -z $1 ]]; then read -p "Domain: " domain;
elif [[ $1 == '.' ]]; then domain=$(pwd -P | sed 's:/chroot::' | cut -d/ -f4);
else domain=$1; fi;
csrfile="/home/*/var/${domain}/ssl/${domain}.csr"
if [[ -f $(echo $csrfile) ]]; then
md5=$(openssl req -in $csrfile -outform DER | openssl dgst -md5 | awk '{print $2}' | sed 's/\(.*\)/\U\1/g');
sha1=$(openssl req -in $csrfile -outform DER | openssl dgst -sha1 | awk '{print $2}' | sed 's/\(.*\)/\U\1/g');
echo -e "${sha1}\ncomodoca.com" > ${md5}.txt; chown $(getusr). ${md5}.txt
else echo "Could not find csr for ${domain}!"; fi