#!/usr/bin/env ruby # -*- coding: utf-8 -*- 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