Class: OpenSSL::X509::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/jopenssl23/openssl/x509.rb,
lib/jopenssl21/openssl/x509.rb,
lib/jopenssl22/openssl/x509.rb,
lib/jopenssl19/openssl/x509-internal.rb

Overview

class ExtensionFactory

def create_extension(*arg)
  if arg.size > 1
    create_ext(*arg)
  else
    send("create_ext_from_"+arg[0].class.name.downcase, arg[0])
  end
end

def create_ext_from_array(ary)
  raise ExtensionError, "unexpected array form" if ary.size > 3
  create_ext(ary[0], ary[1], ary[2])
end

def create_ext_from_string(str) # "oid = critical, value"
  oid, value = str.split(/=/, 2)
  oid.strip!
  value.strip!
  create_ext(oid, value)
end

def create_ext_from_hash(hash)
  create_ext(hash["oid"], hash["value"], hash["critical"])
end

end

class Extension

def ==(other)
  return false unless Extension === other
  to_der == other.to_der
end

def to_s # "oid = critical, value"
  str = self.oid
  str << " = "
  str << "critical, " if self.critical?
  str << self.value.gsub(/\n/, ", ")
end

def to_h # {"oid"=>sn|ln, "value"=>value, "critical"=>true|false}
  {"oid"=>self.oid,"value"=>self.value,"critical"=>self.critical?}
end

def to_a
  [ self.oid, self.value, self.critical? ]
end

end

Defined Under Namespace

Modules: RFC2253DN

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_openssl(str, template = OBJECT_TYPE_TEMPLATE) ⇒ Object Also known as: parse



104
105
106
107
# File 'lib/jopenssl21/openssl/x509.rb', line 104

def parse_openssl(str, template=OBJECT_TYPE_TEMPLATE)
  ary = str.scan(/\s*([^\/,]+)\s*/).collect{|i| i[0].split("=", 2) }
  self.new(ary, template)
end

.parse_rfc2253(str, template = OBJECT_TYPE_TEMPLATE) ⇒ Object



99
100
101
102
# File 'lib/jopenssl21/openssl/x509.rb', line 99

def parse_rfc2253(str, template=OBJECT_TYPE_TEMPLATE)
  ary = OpenSSL::X509::Name::RFC2253DN.scan(str)
  self.new(ary, template)
end

Instance Method Details

#pretty_print(q) ⇒ Object



112
113
114
115
116
117
# File 'lib/jopenssl22/openssl/x509.rb', line 112

def pretty_print(q)
  q.object_group(self) {
    q.text ' '
    q.text to_s(OpenSSL::X509::Name::RFC2253)
  }
end