-
Notifications
You must be signed in to change notification settings - Fork 0
/
csr_gen.rb
37 lines (35 loc) · 1020 Bytes
/
csr_gen.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Creates a CSR and private key for an SSL cert.
class Cert
def self.details
@country = 'US'
puts 'Enter common name (url)'
@cn = gets.chomp.downcase
puts 'Is this a cert to an iseatz domain? [y/n]'
input = gets.chomp.downcase
if input == 'y'
@state = 'Louisiana'
@city = 'New Orleans'
@org = 'iSeatz'
else
puts 'Enter the organization name'
@org = gets.chomp
puts 'Enter the state'
@state = gets.chomp
puts 'Enter a city'
@city = gets.chomp
end
verify
end
def self.verify
puts 'Is this correct? [y/n]'
puts "org= #{@org} city= #{@city} state= #{@state} country= #{@country} cn= #{@cn}"
answer = gets.chomp
if answer == 'y'
@filename = @cn.gsub!('*', 'star').gsub!('.', '_')
system "openssl req -new -newkey rsa:2048 -nodes -out #{@filename}.csr -keyout #{@filename}.key -subj '/C=#{@country}/ST=#{@state}/L=#{@city}/O=#{@org}/CN=#{@cn}'"
else
details
end
end
end
Cert.details