debian-mirror-gitlab/lib/gitlab/email/smime/certificate.rb

35 lines
701 B
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
module Gitlab
module Email
module Smime
class Certificate
attr_reader :key, :cert
def key_string
@key.to_s
end
def cert_string
@cert.to_pem
end
def self.from_strings(key_string, cert_string)
2020-03-09 13:42:32 +05:30
key = OpenSSL::PKey::RSA.new(key_string)
cert = OpenSSL::X509::Certificate.new(cert_string)
2019-12-04 20:38:33 +05:30
new(key, cert)
end
def self.from_files(key_path, cert_path)
from_strings(File.read(key_path), File.read(cert_path))
end
def initialize(key, cert)
@key = key
@cert = cert
end
end
end
end
end