In Files

  • openssl/lib/openssl/x509.rb

Class/Module Index [+]

Quicksearch

OpenSSL::X509::Name::RFC2253DN

Public Instance Methods

expand_hexstring(str) click to toggle source
 
               # File openssl/lib/openssl/x509.rb, line 97
def expand_hexstring(str)
  return nil unless str
  der = str.gsub(HexPair){$&.to_i(16).chr }
  a1 = OpenSSL::ASN1.decode(der)
  return a1.value, a1.tag
end
            
expand_pair(str) click to toggle source
 
               # File openssl/lib/openssl/x509.rb, line 85
def expand_pair(str)
  return nil unless str
  return str.gsub(Pair){
    pair = $&
    case pair.size
    when 2 then pair[1,1]
    when 3 then Integer("0x#{pair[1,2]}").chr
    else raise OpenSSL::X509::NameError, "invalid pair: #{str}"
    end
  }
end
            
expand_value(str1, str2, str3) click to toggle source
 
               # File openssl/lib/openssl/x509.rb, line 104
def expand_value(str1, str2, str3)
  value = expand_pair(str1)
  value, tag = expand_hexstring(str2) unless value
  value = expand_pair(str3) unless value
  return value, tag
end
            
scan(dn) click to toggle source
 
               # File openssl/lib/openssl/x509.rb, line 111
def scan(dn)
  str = dn
  ary = []
  while true
    if md = TypeAndValue.match(str)
      remain = md.post_match
      type = md[1]
      value, tag = expand_value(md[2], md[3], md[4]) rescue nil
      if value
        type_and_value = [type, value]
        type_and_value.push(tag) if tag
        ary.unshift(type_and_value)
        if remain.length > 2 && remain[0] == ?,
          str = remain[1..-1]
          next
        elsif remain.length > 2 && remain[0] == ?+
          raise OpenSSL::X509::NameError,
            "multi-valued RDN is not supported: #{dn}"
        elsif remain.empty?
          break
        end
      end
    end
    msg_dn = dn[0, dn.length - str.length] + " =>" + str
    raise OpenSSL::X509::NameError, "malformed RDN: #{msg_dn}"
  end
  return ary
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus