@@ -15,6 +15,8 @@ ca_system="/etc/ssl/certs/ca-certificates.crt"
1515# Create the temporary output
1616temp_file=$( mktemp)
1717
18+
19+
1820# Remove temporary files on exit
1921trap cleanup 1 2 3 6
2022cleanup ()
@@ -38,6 +40,19 @@ for ca_file in $cert_files; do
3840 # Get the key type
3941 key_type=$( sed -En ' s/.*BEGIN (EC|RSA) PRIVATE KEY.*/\1/p' " $key_file " )
4042
43+ # Check the ports used by TLS records if any
44+ dane_ports=$( pdnsutil list-zone " $domain " | sed -En " s/^_([0-9]+)\\ ._(tcp|udp)\\ .$subdomain \\ .$domain .*TLSA.*/\\ 1/p" )
45+
46+ dane_status=" "
47+ for port in $dane_ports ; do
48+ valid=$( danetool --port $port --check " $subdomain .$domain " 2>&1 | grep -c ' Certificate matches' )
49+ if [ " $valid " = " 0" ]; then
50+ dane_status=" Error"
51+ break
52+ fi
53+ dane_status=" OK"
54+ done
55+
4156 # Check modulus
4257 key_modulus=" "
4358 crt_modulus=" "
@@ -77,22 +92,22 @@ for ca_file in $cert_files; do
7792 bar=$( printf " %02d [%-10s]" " $valid_days " " $bar " )
7893
7994 if [ " $key_modulus " != " $crt_modulus " ]; then
80- printf " %s|%s|%s|%s|%s|%s|%s|%s|Mismatch!\n" \
81- " $subdomain " " $from_short " " $till_short " " $bar " " $issuer " " $sans " " $key_type " " $status " >> " $temp_file "
95+ printf " %s|%s|%s|%s|%s|%s|%s|%s|%s| Mismatch!\n" \
96+ " $subdomain " " $from_short " " $till_short " " $bar " " $issuer " " $sans " " $key_type " " $dane_status " " $ status" >> " $temp_file "
8297 elif openssl verify -trusted " $ca_system " -trusted " $ca_file " " $cert_file " > /dev/null 2>&1 ; then
83- printf " %s|%s|%s|%s|%s|%s|%s|%s|OK\n" \
84- " $subdomain " " $from_short " " $till_short " " $bar " " $issuer " " $sans " " $key_type " " $status " >> " $temp_file "
98+ printf " %s|%s|%s|%s|%s|%s|%s|%s|%s| OK\n" \
99+ " $subdomain " " $from_short " " $till_short " " $bar " " $issuer " " $sans " " $key_type " " $dane_status " " $ status" >> " $temp_file "
85100 else
86101 error=$( openssl verify -trusted " $ca_system " -trusted " $ca_file " " $cert_file " 2>&1 | sed -En ' s/.*: //p' )
87102 error=$( echo " $error " | tr ' \n' ' ,' | sed ' s/,$//' | sed ' s/,/, /g' )
88- printf " %s|%s|%s|%s|%s|%s|%s|%s|$error \n" \
89- " $subdomain " " $from_short " " $till_short " " $bar " " $issuer " " $sans " " $key_type " " $status " >> " $temp_file "
103+ printf " %s|%s|%s|%s|%s|%s|%s|%s|%s| $error \n" \
104+ " $subdomain " " $from_short " " $till_short " " $bar " " $issuer " " $sans " " $key_type " " $dane_status " " $ status" >> " $temp_file "
90105 fi
91106
92107done
93108
94109# Display the output table formatted
95- columns=' Domain,Valid from,Valid until,Days left,Issuer,Full domains list,Type,Status,Details'
110+ columns=' Domain,Valid from,Valid until,Days left,Issuer,Full domains list,Type,DANE, Status,Details'
96111column -t -s ' |' -o ' | ' -N " $columns " -W Status " $temp_file "
97112
98113# Remove temporary files
0 commit comments