diff options
author | Kazuki Yamaguchi <[email protected]> | 2024-08-24 13:29:50 +0900 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2024-11-14 11:21:39 +0900 |
commit | a0f1f161452e9a8c3d017ffbfce5744c775b668f (patch) | |
tree | 03135fbe9a879e6921ba0a1596e47a6b8f4d26b4 /test/openssl | |
parent | 4e7e2e9e8914e1fcbe8410634393525a183b491c (diff) |
asn1: fix ObjectId#==
Compare by the dotted decimal notation rather than the NID.
OpenSSL::ASN1::ObjectId can store OIDs that are not registered in
OpenSSL's internal table. NID is not defined for such an OID, but it is
not an error.
The == method also should not raise TypeError if the other object is
not an instance of OpenSSL::ASN1::ObjectId.
Fixes: https://github.com/ruby/openssl/issues/791
Diffstat (limited to 'test/openssl')
-rw-r--r-- | test/openssl/test_asn1.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb index 7b1722e5df..354b587895 100644 --- a/test/openssl/test_asn1.rb +++ b/test/openssl/test_asn1.rb @@ -326,7 +326,9 @@ class OpenSSL::TestASN1 < OpenSSL::TestCase oid = (0...100).to_a.join(".").b obj = OpenSSL::ASN1::ObjectId.new(oid) assert_equal oid, obj.oid + end + def test_object_identifier_equality aki = [ OpenSSL::ASN1::ObjectId.new("authorityKeyIdentifier"), OpenSSL::ASN1::ObjectId.new("X509v3 Authority Key Identifier"), @@ -341,17 +343,22 @@ class OpenSSL::TestASN1 < OpenSSL::TestCase aki.each do |a| aki.each do |b| - assert a == b + assert_equal true, a == b end ski.each do |b| - refute a == b + assert_equal false, a == b end end - assert_raise(TypeError) { - OpenSSL::ASN1::ObjectId.new("authorityKeyIdentifier") == nil - } + obj1 = OpenSSL::ASN1::ObjectId.new("1.2.34.56789.10") + obj2 = OpenSSL::ASN1::ObjectId.new("1.2.34.56789.10") + obj3 = OpenSSL::ASN1::ObjectId.new("1.2.34.56789.11") + omit "OID 1.2.34.56789.10 is registered" if obj1.sn + assert_equal true, obj1 == obj2 + assert_equal false, obj1 == obj3 + + assert_equal false, OpenSSL::ASN1::ObjectId.new("authorityKeyIdentifier") == nil end def test_sequence |