@@ -434,6 +434,31 @@ def test_tbs_precert_bytes
434434 assert_equal 7 , seq . value . size
435435 end
436436
437+ def test_eq
438+ now = Time . now
439+ ca = OpenSSL ::X509 ::Name . parse ( '/DC=org/DC=ruby-lang/CN=CA' )
440+ ee = OpenSSL ::X509 ::Name . parse ( '/DC=org/DC=example/CN=ServerCert' )
441+ ca_key = OpenSSL ::PKey ::RSA . new ( TEST_KEY_RSA1024 )
442+ ee_key = OpenSSL ::PKey ::RSA . new ( TEST_KEY_RSA1024 )
443+
444+ cacert = issue_cert ( ca , ca_key , 1 , [ ] , nil , nil ,
445+ not_before : now , not_after : now + 3600 )
446+ cert1 = issue_cert ( ee , ee_key , 2 , [ ] , cacert , ca_key ,
447+ not_before : now , not_after : now + 3600 )
448+ cert2 = issue_cert ( ee , ee_key , 2 , [ ] , cacert , ca_key ,
449+ not_before : now , not_after : now + 3600 )
450+ cert3 = issue_cert ( ee , ee_key , 3 , [ ] , cacert , ca_key ,
451+ not_before : now , not_after : now + 3600 )
452+ cert4 = issue_cert ( ee , ee_key , 2 , [ ] , cacert , ca_key ,
453+ digest : 'sha512' , not_before : now , not_after : now + 3600 )
454+
455+ assert_equal false , cert1 == 12345
456+ assert_equal true , cert1 == cert2
457+ assert_equal false , cert1 == cert3
458+ assert_equal false , cert1 == cert4
459+ assert_equal false , cert3 == cert4
460+ end
461+
437462 def test_cert_loading_regression
438463 cert_text = "0\x82 \x01 \xAD 0\x82 \x01 \xA1 \xA0 \x03 \x02 \x01 \x02 \x02 \x01 \x01 0\x03 \x06 \x01 \x00 0g1\v 0\t \x06 \x03 U\x04 \x06 \x13 \x02 US1\x13 0\x11 \x06 \x03 U\x04 \b \f \n California1\x15 0\x13 \x06 \x03 U\x04 \a \f \f Santa Monica1\x11 0\x0F \x06 \x03 U\x04 \n \f \b OneLogin1\x19 0\x17 \x06 \x03 U\x04 \x03 \f \x10 app.onelogin.com0\x1E \x17 \r 100309095845Z\x17 \r 150309095845Z0g1\v 0\t \x06 \x03 U\x04 \x06 \x13 \x02 US1\x13 0\x11 \x06 \x03 U\x04 \b \f \n California1\x15 0\x13 \x06 \x03 U\x04 \a \f \f Santa Monica1\x11 0\x0F \x06 \x03 U\x04 \n \f \b OneLogin1\x19 0\x17 \x06 \x03 U\x04 \x03 \f \x10 app.onelogin.com0\x81 \x9F 0\r \x06 \t *\x86 H\x86 \xF7 \r \x01 \x01 \x01 \x05 \x00 \x03 \x81 \x8D \x00 0\x81 \x89 \x02 \x81 \x81 \x00 \xE8 \xD2 \xBB W\xE3 ?/\x1D \xE7 \x0E \x10 \xC8 \xBD ~\xCD \xDE !#\r L\x92 G\xDF \xE1 f?L\xB1 \xBC 9\x99 \x14 \xE5 \x84 \xD2 Zi\x87 <>d\xBD \x81 \xF9 \xBA \x85 \xD2 \xFF \xAA \x90 \xF3 Z\x97 \xA5 \x1D \xB0 W\xC0 \x93 \xA3 \x06 IP\xB8 4\xF5 \xD7 Qu\x19 \xFC B\xCA \xA3 \xD4 \\ \x8E \v \x9B %\x13 |\xB6 m\x9D \xA8 \x16 \xE6 \xBB \xDA \x87 \xFF \xE3 \xD7 \xE9 \xBA 9\xC5 O\xA2 \xA7 C\xAD B\x04 \xCA \xA5 \x0E \x84 \xD0 \xA8 \xE4 \xFA \xDA \xF1 \x89 \xF2 s\xFA 1\x95 \xAF \x03 \xAB 1\xAA \xE7 y\x02 \x03 \x01 \x00 \x01 0\x03 \x06 \x01 \x00 \x03 \x01 \x00 "
439464 assert cert = OpenSSL ::X509 ::Certificate . new ( cert_text )
0 commit comments