exe/ewssl in EndlessWaffleCLI-0.1.2 vs exe/ewssl in EndlessWaffleCLI-0.1.4
- old
+ new
@@ -8,11 +8,11 @@
require 'fileutils'
require 'console_table'
require 'openssl'
-
+@upload_to_iam=false
@results_directory = "#{ENV["HOME"]}/.ewssl"
@config_file = "#{ENV["HOME"]}/.ewssl.json"
example_config = {
:snpp => {
@@ -48,10 +48,11 @@
puts "Options:"
puts "-h or --help ".ljust(30) +"-> Display this help message"
puts "-c or --config".ljust(30) +"-> Specifiy Config to use"
puts "-f or --fqdn".ljust(30) +"-> Domain name you want a CRT for"
puts "-l or --list".ljust(30) + "-> List Valid Configs"
+ puts "-i or --iam".ljust(30) + "-> Upload Certificate to IAM"
puts
exit 1
end
def parse_cli
@@ -61,11 +62,12 @@
parser = GetoptLong.new
parser.set_options(["-h", "--help", GetoptLong::NO_ARGUMENT],
["-c", "--config", GetoptLong::NO_ARGUMENT],
["-f", "--fqdn", GetoptLong::NO_ARGUMENT],
- ["-l", "--list", GetoptLong::NO_ARGUMENT]
+ ["-l", "--list", GetoptLong::NO_ARGUMENT],
+ ["-i", "--iam", GetoptLong::NO_ARGUMENT]
)
begin
begin
opt,arg = parser.get_option
@@ -76,10 +78,12 @@
exit
when "-c" || "--config"
@active_config = ARGV[0].strip().downcase()
when "-f" || "--fqdn"
@fqdn = ARGV[0].strip().downcase()
+ when "-i" || "--iam"
+ @upload_to_iam = true
when "-l" || "--list"
@list = true
end
rescue => err
puts "#{err.class()}: #{err.message}"
@@ -184,10 +188,18 @@
File.open(@my_databag_path,"w") do |f|
f.write(JSON.pretty_generate(databag))
end
end
+def upload_to_iam
+ command = "aws iam upload-server-certificate \
+ --server-certificate-name #{@fqdn.gsub('*','star')}-#{@timestamp} \
+ --certificate-body file://#{@my_cert_path} \
+ --private-key file://#{@my_key_path}\
+ --certificate-chain file://#{@my_chain_path}"
+ system(command)
+end
parse_cli
if @list == true
list
else
@@ -205,6 +217,10 @@
generateKey
generateCSR
storeSignedCert
storeCertificateChain
genDataBag
+ if @upload_to_iam == true
+ upload_to_iam
+ end
+
end