Commit 8cac2af
Changed files (2)
lib
saml
exe/saml-kit-create-self-signed-certificate
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+require 'saml/kit'
+
+password = STDIN.read.strip
+certificate, private_key = Saml::Kit::SelfSignedCertificate.new(password).create
+
+puts
+puts "Certificate:"
+print certificate
+
+puts
+puts "Private Key:"
+puts private_key
+
+puts
+puts "Private Key Password:"
+puts password.inspect
lib/saml/kit/self_signed_certificate.rb
@@ -9,9 +9,9 @@ module Saml
rsa_key = OpenSSL::PKey::RSA.new(2048)
public_key = rsa_key.public_key
certificate = OpenSSL::X509::Certificate.new
- certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse("/C=CA/ST=Alberta/L=Calgary/O=Xsig/OU=Xsig/CN=Xsig")
+ certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse("/C=CA/ST=Alberta/L=Calgary/O=SamlKit/OU=SamlKit/CN=SamlKit")
certificate.not_before = DateTime.now.beginning_of_day
- certificate.not_after = 1.year.from_now.end_of_day
+ certificate.not_after = 5.years.from_now.end_of_day
certificate.public_key = public_key
certificate.serial = 0x0
certificate.version = 2
@@ -22,7 +22,7 @@ module Saml
certificate.sign(rsa_key, OpenSSL::Digest::SHA256.new)
[
certificate.to_pem,
- rsa_key.to_pem(OpenSSL::Cipher::Cipher.new('des3'), @password)
+ rsa_key.to_pem(OpenSSL::Cipher::Cipher.new('AES-256-CBC'), @password)
]
end
end