Module: OpenSSL::X509::Name::RFC2253DN
- Defined in:
- lib/openssl/x509.rb
Constant Summary collapse
- Special =
',=+<>#;'
- HexChar =
/[0-9a-fA-F]/
- HexPair =
/#{HexChar}#{HexChar}/
- HexString =
/#{HexPair}+/
- Pair =
/\\(?:[#{Special}]|\\|"|#{HexPair})/
- StringChar =
/[^\\"#{Special}]/
- QuoteChar =
/[^\\"]/
- AttributeType =
/[a-zA-Z][0-9a-zA-Z]*|[0-9]+(?:\.[0-9]+)*/
- AttributeValue =
/ (?!["#])((?:#{StringChar}|#{Pair})*)| \#(#{HexString})| "((?:#{QuoteChar}|#{Pair})*)" /x
- TypeAndValue =
/\A(#{AttributeType})=#{AttributeValue}/
Class Method Summary collapse
- .expand_hexstring(str) ⇒ Object
- .expand_pair(str) ⇒ Object
- .expand_value(str1, str2, str3) ⇒ Object
- .scan(dn) ⇒ Object
Class Method Details
.expand_hexstring(str) ⇒ Object
237 238 239 240 241 242 |
# File 'lib/openssl/x509.rb', line 237 def (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) ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/openssl/x509.rb', line 225 def (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) ⇒ Object
244 245 246 247 248 249 |
# File 'lib/openssl/x509.rb', line 244 def (str1, str2, str3) value = (str1) value, tag = (str2) unless value value = (str3) unless value return value, tag end |
.scan(dn) ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/openssl/x509.rb', line 251 def scan(dn) str = dn ary = [] while true if md = TypeAndValue.match(str) remain = md.post_match type = md[1] value, tag = (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 |