aboutsummaryrefslogtreecommitdiffstats
path: root/lib/openssl
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2021-11-01 17:23:07 +0900
committerKazuki Yamaguchi <k@rhe.jp>2021-11-01 17:27:30 +0900
commit74041a35d49ac64baf268e0e2e87a6a4311b4f63 (patch)
tree8f06d3be5d87b75515ed8bbbf0725ed2381b2a89 /lib/openssl
parentb887ef4f36d8972857b122559e92dc4286d7e069 (diff)
downloadruby-openssl-74041a35d49ac64baf268e0e2e87a6a4311b4f63.tar.gz
x509name: improve docs for X509::Name
Add docs for X509::Name.parse_openssl and X509::Name.parse_rfc2253, which are currently undocumented despite being widely used. Small changes are also made to #to_s and the class description to recommend using RFC 2253-based methods. Fixes: https://github.com/ruby/openssl/issues/470
Diffstat (limited to 'lib/openssl')
-rw-r--r--lib/openssl/x509.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/openssl/x509.rb b/lib/openssl/x509.rb
index 448941f7..f973f4f4 100644
--- a/lib/openssl/x509.rb
+++ b/lib/openssl/x509.rb
@@ -279,11 +279,29 @@ module OpenSSL
end
class << self
+ # Parses the UTF-8 string representation of a distinguished name,
+ # according to RFC 2253.
+ #
+ # See also #to_utf8 for the opposite operation.
def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
self.new(ary, template)
end
+ # Parses the string representation of a distinguished name. Two
+ # different forms are supported:
+ #
+ # - \OpenSSL format (<tt>X509_NAME_oneline()</tt>) used by
+ # <tt>#to_s</tt>. For example: <tt>/DC=com/DC=example/CN=nobody</tt>
+ # - \OpenSSL format (<tt>X509_NAME_print()</tt>)
+ # used by <tt>#to_s(OpenSSL::X509::Name::COMPAT)</tt>. For example:
+ # <tt>DC=com, DC=example, CN=nobody</tt>
+ #
+ # 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.
def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
if str.start_with?("/")
# /A=B/C=D format