File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,36 @@ cert-chain() {
130130 done
131131}
132132
133+ cert-resource-record-valid () {
134+
135+ # cert-resource-record-valid - Check if a specified DNS resource record matches the expected value and includes input validation.
136+ #
137+ # Usage: cert-resource-record-valid <name> <type> <value>
138+
139+ [[ " $# " -ne 3 ]] && __bma_usage " <name> <type> <value" && return 1
140+
141+ local name=" $1 "
142+ local type=" $2 "
143+ local value=" $3 "
144+
145+ # Perform the DNS query
146+ local output=$( dig +noall +answer " $name " " $type " )
147+
148+ # Print the output of the DNS query
149+ echo " Query output:"
150+ echo " $output "
151+
152+ # Check if the expected value is in the output
153+ if echo " $output " | grep -q " $value " ; then
154+ echo " The DNS record is valid."
155+ return 0
156+ else
157+ echo " The DNS record is invalid or does not exist."
158+ return 1
159+ fi
160+ }
161+
162+
133163# openssl verify -CAfile trusted-ca.crt -untrusted chain.crt cert.crt
134164
135165cert-verify () {
You can’t perform that action at this time.
0 commit comments