Sha256: 09949758f2ef2fe466d4e31f57bf6251f57ed80aaee5e147efa2a42a63693d7c

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

module Saml
  module Kit
    module Cli
      class Certificate < Thor
        desc "keypair", "Create a key pair using a self signed certificate."
        method_option :format, default: "pem", required: false, enum: ["pem", "env"]
        method_option :passphrase, default: nil, required: false
        def keypair
          passphrase = options[:passphrase]
          format = options[:format]
          generator = ::Xml::Kit::SelfSignedCertificate.new
          certificate, private_key = generator.create(passphrase: passphrase)

          if "pem" == format
            say "** BEGIN PEM Format **", :green
            print certificate
            say private_key
            say "***********************", :green
          else
            say "** BEGIN ENV Format **", :green
            say "X509_CERTIFICATE=" + certificate.inspect
            say
            say "PRIVATE_KEY=" + private_key.inspect
            say "***********************", :green
          end

          say
          say "Private Key Passphrase:", :green
          say passphrase.inspect
        end

        desc "dump", "Dump the details of a X509 Certificate."
        def dump(raw)
          certificate = ::Xml::Kit::Certificate.new(raw, use: :unknown)
          x509 = certificate.x509
          print_table [
            ["Subject", "Issuer", "Serial", "Not Before", "Not After", "Fingerprint"],
            [x509.subject, x509.issuer, x509.serial, x509.not_before, x509.not_after, certificate.fingerprint]
          ]
          say x509.to_text, :green
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
saml-kit-cli-0.3.6 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.3.5 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.3.4 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.3.3 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.3.2 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.3.1 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.3.0 lib/saml/kit/cli/certificate.rb
saml-kit-cli-0.2.0 lib/saml/kit/cli/certificate.rb