Class: Saml::Kit::SelfSignedCertificate
- Inherits:
-
Object
- Object
- Saml::Kit::SelfSignedCertificate
- Defined in:
- lib/saml/kit/self_signed_certificate.rb
Constant Summary collapse
- SUBJECT =
"/C=CA/ST=Alberta/L=Calgary/O=SamlKit/OU=SamlKit/CN=SamlKit"
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(password) ⇒ SelfSignedCertificate
constructor
A new instance of SelfSignedCertificate.
Constructor Details
#initialize(password) ⇒ SelfSignedCertificate
Returns a new instance of SelfSignedCertificate.
6 7 8 |
# File 'lib/saml/kit/self_signed_certificate.rb', line 6 def initialize(password) @password = password end |
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/saml/kit/self_signed_certificate.rb', line 10 def create 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(SUBJECT) certificate.not_before = DateTime.now.beginning_of_day certificate.not_after = 30.days.from_now certificate.public_key = public_key certificate.serial = 0x0 certificate.version = 2 certificate.sign(rsa_key, OpenSSL::Digest::SHA256.new) [ certificate.to_pem, rsa_key.to_pem(OpenSSL::Cipher.new('AES-256-CBC'), @password) ] end |