Sha256: beebea48196b19c002348ec9aa17c24e2e049818b5eb7500e6cd652cdd333243

Contents?: true

Size: 881 Bytes

Versions: 10

Compression:

Stored size: 881 Bytes

Contents

module Saml
  module Kit
    class SelfSignedCertificate
      SUBJECT="/C=CA/ST=Alberta/L=Calgary/O=SamlKit/OU=SamlKit/CN=SamlKit"

      def initialize(password)
        @password = password
      end

      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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
saml-kit-0.2.13 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.12 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.11 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.10 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.9 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.8 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.7 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.6 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.5 lib/saml/kit/self_signed_certificate.rb
saml-kit-0.2.4 lib/saml/kit/self_signed_certificate.rb