Sha256: 1ef5172966bc21191485374085862f4fa060d2fb51d6fad3ca52ef25dc7c2638

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

# frozen_string_literal: true

module Saml
  module Kit
    module Cli
      class GenerateKeyPair
        attr_reader :passphrase, :format

        def initialize(passphrase:, format:)
          @passphrase = passphrase
          @format = format
        end

        def run(shell)
          certificate, private_key = generate
          if pem?
            shell.say certificate
            shell.say private_key
          else
            shell.say 'X509_CERTIFICATE=' + certificate.inspect
            shell.say 'PRIVATE_KEY=' + private_key.inspect
          end
          shell.say 'Private Key Passphrase:', :green
          shell.say passphrase.inspect
        end

        private

        def generate
          generator = ::Xml::Kit::SelfSignedCertificate.new
          generator.create(passphrase: passphrase)
        end

        def pem?
          format == 'pem'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
saml-kit-cli-0.3.8 lib/saml/kit/cli/generate_key_pair.rb
saml-kit-cli-0.3.7 lib/saml/kit/cli/generate_key_pair.rb