Sha256: 9a10eca8d6522602ab5acd4bc7966612b2e4eadbd49bdcdafbfe3677bfa74b98

Contents?: true

Size: 664 Bytes

Versions: 13

Compression:

Stored size: 664 Bytes

Contents

require 'ritm/certs/ca'

module Doraemon

  class Cert

    def self.cert_root
      File.join(Dir.home, ".doraemon")
    end

    def self.cert_path
      File.join(Cert.cert_root, "doraemon.crt")
    end

    def self.key_path
      File.join(Cert.cert_root, "doraemon.key")
    end

    def self.generate_cert
      crt_root = Cert.cert_root
      Dir.mkdir(crt_root) unless Dir.exist?(crt_root)

      if !File.exist?(Cert.cert_path)
        ca = Ritm::CA.create common_name: 'Doraemon'
        File.write(Cert.cert_path, ca.pem)
        File.write(Cert.key_path, ca.private_key.to_s)
        puts 'doraemon.crt generate success.'
      end
    end

  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
doraemon-1.0.12 lib/doraemon/utils/cert.rb
doraemon-1.0.11 lib/doraemon/utils/cert.rb
doraemon-1.0.10 lib/doraemon/utils/cert.rb
doraemon-1.0.9 lib/doraemon/utils/cert.rb
doraemon-1.0.8 lib/doraemon/utils/cert.rb
doraemon-1.0.7 lib/doraemon/utils/cert.rb
doraemon-1.0.6 lib/doraemon/utils/cert.rb
doraemon-1.0.5 lib/doraemon/utils/cert.rb
doraemon-1.0.4 lib/doraemon/utils/cert.rb
doraemon-1.0.3 lib/doraemon/utils/cert.rb
doraemon-1.0.2 lib/doraemon/utils/cert.rb
doraemon-1.0.1 lib/doraemon/utils/cert.rb
doraemon-1.0.0 lib/doraemon/utils/cert.rb