From 98d8f6128e7f8378bf6e34b5c12fae9bdd6d3f10 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Thu, 31 Aug 2023 14:12:57 +0900 Subject: [PATCH] [ruby/openssl] x509ext: test OpenSSL::X509::ExtensionFactory#create_ext with ln OpenSSL::X509::ExtensionFactory#create_ext and #create_extensions accepts both sn (short names) and ln (long names) for registered OIDs. This is different from the behavior of the openssl command-line utility which accepts only sn in openssl.cnf keys. Add a test case to check this. https://github.com/ruby/openssl/commit/91ae46c8d7 --- test/openssl/test_x509ext.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/openssl/test_x509ext.rb b/test/openssl/test_x509ext.rb index 7ad010d1ed..c04c06574f 100644 --- a/test/openssl/test_x509ext.rb +++ b/test/openssl/test_x509ext.rb @@ -70,6 +70,14 @@ class OpenSSL::TestX509Extension < OpenSSL::TestCase assert_match(%r{http://cps.example.com}, cp.value) end + def test_factory_create_extension_sn_ln + ef = OpenSSL::X509::ExtensionFactory.new + bc_sn = ef.create_extension("basicConstraints", "critical, CA:TRUE, pathlen:2") + bc_ln = ef.create_extension("X509v3 Basic Constraints", "critical, CA:TRUE, pathlen:2") + assert_equal(@basic_constraints.to_der, bc_sn.to_der) + assert_equal(@basic_constraints.to_der, bc_ln.to_der) + end + def test_dup ext = OpenSSL::X509::Extension.new(@basic_constraints.to_der) assert_equal(@basic_constraints.to_der, ext.to_der)