cd5466
From bb0f57aeb4de36a3b2b8b8cb01d25b32af0357d3 Mon Sep 17 00:00:00 2001
cd5466
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
cd5466
Date: Wed, 27 Oct 2021 16:28:24 +0200
cd5466
Subject: [PATCH] Provide distinguished name which will be correctly parsed.
cd5466
cd5466
It seems that since ruby openssl 2.1.0 [[1]], the distinguished name
cd5466
submitted to `OpenSSL::X509::Name.parse` is not correctly parsed if it
cd5466
does not contain the first slash:
cd5466
cd5466
~~~
cd5466
$ ruby -v
cd5466
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
cd5466
cd5466
$ gem list | grep openssl
cd5466
openssl (default: 2.2.0)
cd5466
cd5466
$ irb -r openssl
cd5466
irb(main):001:0> OpenSSL::X509::Name.parse("CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE)
cd5466
=> "CN = nobody/DC=example"
cd5466
irb(main):002:0> OpenSSL::X509::Name.parse("/CN=nobody/DC=example").to_s(OpenSSL::X509::Name::ONELINE)
cd5466
=> "CN = nobody, DC = example"
cd5466
~~~
cd5466
cd5466
[1]: https://github.com/ruby/openssl/commit/19c67cd10c57f3ab7b13966c36431ebc3fdd653b
cd5466
---
cd5466
 lib/rubygems/security.rb | 2 +-
cd5466
 1 file changed, 1 insertion(+), 1 deletion(-)
cd5466
cd5466
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
cd5466
index c80639af6d..12de141f36 100644
cd5466
--- a/lib/rubygems/security.rb
cd5466
+++ b/lib/rubygems/security.rb
cd5466
@@ -510,7 +510,7 @@ def self.email_to_name(email_address)
cd5466
 
cd5466
     dcs = dcs.split '.'
cd5466
 
cd5466
-    name = "CN=#{cn}/#{dcs.map {|dc| "DC=#{dc}" }.join '/'}"
cd5466
+    name = "/CN=#{cn}/#{dcs.map {|dc| "DC=#{dc}" }.join '/'}"
cd5466
 
cd5466
     OpenSSL::X509::Name.parse name
cd5466
   end
cd5466
-- 
cd5466
2.32.0
cd5466