class method
OpenSSL::X509::Name.parse_openssl
(::String str, ?::OpenSSL::X509::Name::template template) -> instance
parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
ext/openssl/lib/openssl/x509.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/ext/openssl/lib/openssl/x509.rb, line 305
def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
if str.start_with?("/")
# /A=B/C=D format
ary = str[1..-1].split("/").map { |i| i.split("=", 2) }
else
# Comma-separated
ary = str.split(",").map { |i| i.strip.split("=", 2) }
end
self.new(ary, template)
end
Parses the string representation of a distinguished name. Two different forms are supported:
-
OpenSSL format (
X509_NAME_oneline()) used byto_s. For example:/DC=com/DC=example/CN=nobody -
OpenSSL format (
X509_NAME_print()) used by#to_s(OpenSSL::X509::Name::COMPAT). For example:DC=com, DC=example, CN=nobody
Neither of them is standardized and has quirks and inconsistencies in handling of escaped characters or multi-valued RDNs.
Use of this method is discouraged in new applications. See Name.parse_rfc2253 and to_utf8 for the alternative.