Skip to content

Instantly share code, notes, and snippets.

@niiku-y
Created November 22, 2019 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niiku-y/e4435d6d2f308cbf484940e20eff4946 to your computer and use it in GitHub Desktop.
Save niiku-y/e4435d6d2f308cbf484940e20eff4946 to your computer and use it in GitHub Desktop.
#!/bin/bash
# add subject alternative name to openssl.cnf
# ubunt 18.04
CNF_FILE=/etc/ssl/openssl.cnf
sudo cp ${CNF_FILE} ${CNF_FILE}.org
linenum=$( grep -n "^# Include email address in subject alt name: another PKIX recommendation" ${CNF_FILE} | cut -f 1 -d ':' )
FQDN=hoge.local
IP_ADDR=192.168.0.10
sudo sed -i -e "${linenum}a subjectAltName=@alt_names\
\n[alt_names]\
\nDNS.1 = ${FQDN}\
\nIP.1 = ${IP_ADDR}\
\n" ${CNF_FILE}
echo "result:"
sudo diff ${CNF_FILE} ${CNF_FILE}.org
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment