class SslCertificate::Certificate
Public Instance Methods
alternative_names()
click to toggle source
# File lib/ssl_certificate.rb, line 15 def alternative_names alt_name = extensions.find { |ex| ex.oid == 'subjectAltName' } if alt_name alt_name.value.split(',').map { |dns| dns.strip.gsub(/^DNS:/, '') } else nil end end
check_fqdn(fqdn)
click to toggle source
# File lib/ssl_certificate.rb, line 29 def check_fqdn(fqdn) matched = match_between(fqdn, common_name) if matched.nil? && alternative_names matched = alternative_names.find { |name| match_between(fqdn, name) } end matched ? true : false end
check_private_key_str(private_key_str)
click to toggle source
# File lib/ssl_certificate.rb, line 24 def check_private_key_str(private_key_str) private_key = OpenSSL::PKey::RSA.new(private_key_str) check_private_key(private_key) end
common_name()
click to toggle source
# File lib/ssl_certificate.rb, line 6 def common_name common_name = subject.to_a.find { |value| value[0] == 'CN' } if common_name common_name[1] else nil end end
Private Instance Methods
match_between(fqdn, str)
click to toggle source
# File lib/ssl_certificate.rb, line 39 def match_between(fqdn, str) fqdn =~ /\A#{str.gsub('.', '\.').gsub('*', '.*')}\z/ end