Skip to content

Instantly share code, notes, and snippets.

@starx
Created November 2, 2016 10:44
Show Gist options
  • Save starx/4640b11f029af70af601e715955dae61 to your computer and use it in GitHub Desktop.
Save starx/4640b11f029af70af601e715955dae61 to your computer and use it in GitHub Desktop.
Generate x509 Certificate using Expect
/usr/bin/expect -c 'spawn openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./apache.key -out ./apache.crt
expect -re {Country Name \(2 letter code\) [^:]*:} {send "NP\n"}
expect -re {State or Province Name \(full name\) [^:]*:} {send "Bagmati\n"}
expect -re {Locality Name \(eg, city\) [^:]*:} {send "Budhanilkantha\n"}
expect -re {Organization Name \(eg, company\) [^:]*:} {send "nGen Technologies\n"}
expect -re {Organizational Unit Name \(eg, section\) [^:]*:} {send "Software Development\n"}
expect -re {Common Name \(e.g. server FQDN or YOUR name\) [^:]*:} {send "mrnepal.com\n"}
expect -re {Email Address [^:]*:} {send "test@mrnepal.com\n"}
expect eof'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment