Commit fc34335a authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Change validator to check the asn1 flag instead

Fixes the validation with OpenSSL 1.1
parent 4055c2fe
...@@ -19,15 +19,13 @@ class NamedEcdsaKeyValidator < ActiveModel::EachValidator ...@@ -19,15 +19,13 @@ class NamedEcdsaKeyValidator < ActiveModel::EachValidator
private private
UNNAMED_CURVE = "UNDEF"
def explicit_ec?(value) def explicit_ec?(value)
return false unless value return false unless value
pkey = OpenSSL::PKey.read(value) pkey = OpenSSL::PKey.read(value)
return false unless pkey.is_a?(OpenSSL::PKey::EC) return false unless pkey.is_a?(OpenSSL::PKey::EC)
pkey.group.curve_name == UNNAMED_CURVE pkey.group.asn1_flag != OpenSSL::PKey::EC::NAMED_CURVE
rescue OpenSSL::PKey::PKeyError rescue OpenSSL::PKey::PKeyError
false false
end end
......
...@@ -160,7 +160,7 @@ describe PagesDomain do ...@@ -160,7 +160,7 @@ describe PagesDomain do
end end
context 'when curve is set explicitly by parameters' do context 'when curve is set explicitly by parameters' do
it 'adds errors to private key', :quarantine do it 'adds errors to private key' do
domain = build(:pages_domain, :explicit_ecdsa) domain = build(:pages_domain, :explicit_ecdsa)
expect(domain).to be_invalid expect(domain).to be_invalid
......
...@@ -43,7 +43,7 @@ describe NamedEcdsaKeyValidator do ...@@ -43,7 +43,7 @@ describe NamedEcdsaKeyValidator do
context 'with ECDSA certificate with explicit curve params' do context 'with ECDSA certificate with explicit curve params' do
let(:value) { attributes_for(:pages_domain, :explicit_ecdsa)[:key] } let(:value) { attributes_for(:pages_domain, :explicit_ecdsa)[:key] }
it 'adds errors', :quarantine do it 'adds errors' do
expect(value).to be_present expect(value).to be_present
subject subject
......
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