Skip to content

Instantly share code, notes, and snippets.

@zekus
Forked from matthutchinson/nginx_gen_cert.rb
Last active August 29, 2015 14:19
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 zekus/1063d6f0520b9ca36a30 to your computer and use it in GitHub Desktop.
Save zekus/1063d6f0520b9ca36a30 to your computer and use it in GitHub Desktop.
#!/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 "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/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"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment