Browse Source

Wrong SANS when domain contains a minus character

A regexp to extract 'Subject Alternative Name' doesn't work when the domain use a minus character.

For grep regexp, to lose its special meaning inside brackets, the minus character must be placed in the first or last position in the list.

https://www.gnu.org/software/grep/manual/grep.html#Character-Classes-and-Bracket-Expressions
pull/616/head
atisne 5 years ago
parent
commit
27265df667
1 changed files with 1 additions and 2 deletions
  1. +1
    -2
      getssl

+ 1
- 2
getssl View File

@ -2578,11 +2578,10 @@ if [[ ${_CREATE_CONFIG} -eq 1 ]]; then
| openssl x509 2>/dev/null)
EX_SANS="www.${DOMAIN##\*.}"
if [[ -n "${EX_CERT}" ]]; then
# Putting this inside the EX_SANS line below doesn't work on Centos7
escaped_d=${DOMAIN/\*/\\\*}
EX_SANS=$(echo "$EX_CERT" \
| openssl x509 -noout -text 2>/dev/null| grep "Subject Alternative Name" -A2 \
| grep -Eo "DNS:[a-zA-Z 0-9.-\*]*" | sed "s@DNS:${escaped_d}@@g" | grep -v '^$' | cut -c 5-)
| grep -Eo "DNS:[a-zA-Z 0-9.\*-]*" | sed "s@DNS:${escaped_d}@@g" | grep -v '^$' | cut -c 5-)
EX_SANS=${EX_SANS//$'\n'/','}
fi
if [[ -n "${EX_SANS}" ]]; then


Loading…
Cancel
Save