This script comes from HOWTO: Create Your Own Self-Signed Certificate with Subject Alternative Names Using OpenSSL in Ubuntu Bash for Window written by jchandra74
I just put all code snippets into a single bash script file, just run autoCert.sh, then you will get CA , cert and key files.