certificate.rb
464 Bytes
require "openssl"
require 'digest/md5'
class Certificate < ActiveRecord::Base
def key
OpenSSL::PKey::EC.new read_attribute(:key) if read_attribute(:key)
end
def cert
OpenSSL::X509::Certificate.new read_attribute(:cert) if read_attribute(:cert)
end
def key_fpr
Digest::SHA256.hexdigest(key.to_der).upcase
end
def cert_fpr
Digest::SHA256.hexdigest(cert.to_der).upcase
end
private
def _key
end
end
# vim: set et ts=2 sw=2: