Commit 63eb4156 authored by Kamil Trzcinski's avatar Kamil Trzcinski Committed by James Edwards-Jones

Fix certificate validators

parent 8f09ec28
...@@ -16,7 +16,7 @@ class CertificateKeyValidator < ActiveModel::EachValidator ...@@ -16,7 +16,7 @@ class CertificateKeyValidator < ActiveModel::EachValidator
private private
def valid_private_key_pem?(value) def valid_private_key_pem?(value)
return unless value return false unless value
pkey = OpenSSL::PKey::RSA.new(value) pkey = OpenSSL::PKey::RSA.new(value)
pkey.private? pkey.private?
rescue OpenSSL::PKey::PKeyError rescue OpenSSL::PKey::PKeyError
......
...@@ -16,9 +16,9 @@ class CertificateValidator < ActiveModel::EachValidator ...@@ -16,9 +16,9 @@ class CertificateValidator < ActiveModel::EachValidator
private private
def valid_certificate_pem?(value) def valid_certificate_pem?(value)
return unless value return false unless value
OpenSSL::X509::Certificate.new(value) OpenSSL::X509::Certificate.new(value).present?
rescue OpenSSL::X509::CertificateError rescue OpenSSL::X509::CertificateError
nil false
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment