Created
June 25, 2014 17:40
-
-
Save stonean/46fee17f1e5da95e3e70 to your computer and use it in GitHub Desktop.
nginx: create SSL Certs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Pass in the name of the site you wich to create a cert for | |
domain_name = ARGV[0] | |
if domain_name == nil | |
puts "Need a domain name, I can't read minds." | |
else | |
system "openssl genrsa -out #{domain_name}.key 2048" | |
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=GA/L=Roswell/O=Nookwit/OU=IT/CN=#{domain_name}'" | |
system "cp #{domain_name}.key #{domain_name}.key.bak" | |
system "openssl rsa -in #{domain_name}.key.bak -out #{domain_name}.key" | |
system "openssl x509 -req -days 365 -in #{domain_name}.csr -signkey #{domain_name}.key -out #{domain_name}.crt" | |
system "mkdir -p /usr/local/etc/nginx/ssl" | |
system "mv #{domain_name}.* /usr/local/etc/nginx/ssl" | |
system "mkdir -p /usr/local/etc/nginx/logs" | |
system "touch /usr/local/etc/nginx/logs/#{domain_name}-ssl-access.log" | |
system "touch /usr/local/etc/nginx/logs/#{domain_name}-ssl-error.log" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment