Created
October 25, 2016 07:26
-
-
Save msg7086/8ba735ad6b96b1cd519e2ffb53281076 to your computer and use it in GitHub Desktop.
Generate pair of ecc & rsa SSL certificates
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 | |
require 'rake' | |
include FileUtils | |
include Rake | |
domain=ARGV.first | |
commonname=domain | |
country='US' | |
state='.' | |
locality='.' | |
organization='.' | |
organizationalunit='.' | |
email='[email protected]' | |
raise 'Empty domain' if domain.empty? | |
puts "Generating key request for $domain" | |
year = Time.now.year | |
mkdir_p domain | |
Dir.chdir domain do | |
sh "openssl genrsa -out rsa#{year}.key 2048 -noout" if !File.exist? "rsa#{year}.key" | |
sh "openssl ecparam -out ecc#{year}.key -name secp384r1 -genkey" if !File.exist? "ecc#{year}.key" | |
sh "openssl req -new -key rsa#{year}.key -out rsa#{year}.csr \ | |
-subj \"/C=#{country}/ST=#{state}/L=#{locality}/O=#{organization}/OU=#{organizationalunit}/CN=#{commonname}/emailAddress=#{email}\"" | |
sh "openssl req -new -key ecc#{year}.key -out ecc#{year}.csr \ | |
-subj \"/C=#{country}/ST=#{state}/L=#{locality}/O=#{organization}/OU=#{organizationalunit}/CN=#{commonname}/emailAddress=#{email}\"" | |
puts File.read "rsa#{year}.csr" | |
puts File.read "ecc#{year}.csr" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment