Module: OpenSSL::X509::Name::RFC2253DN (Ruby 2.3.2)
Description: Module : OpenSSL::X509::Name::RFC2253DN - Ruby 2.3.2

- Home
- Core 2.3.2
- Std-lib 2.3.2
- Downloads

Support for the Ruby 2.3 series has ended. See here for reference.

### Home Classes Methods

### In Files

- openssl/lib/openssl/x509.rb

### Methods

- #expand_hexstring
- #expand_pair
- #expand_value
- #scan

### Class/Module Index

Quicksearch

- Integer
- OpenSSL::ASN1
- OpenSSL::ASN1::ASN1Data
- OpenSSL::ASN1::ASN1Error
- OpenSSL::ASN1::Constructive
- OpenSSL::ASN1::ObjectId
- OpenSSL::ASN1::Primitive
- OpenSSL::BN
- OpenSSL::BNError
- OpenSSL::Buffering
- OpenSSL::Cipher
- OpenSSL::Cipher::Cipher
- OpenSSL::Cipher::CipherError
- OpenSSL::Config
- OpenSSL::ConfigError
- OpenSSL::Digest
- OpenSSL::Digest::DigestError
- OpenSSL::Engine
- OpenSSL::Engine::EngineError
- OpenSSL::ExtConfig
- OpenSSL::HMAC
- OpenSSL::HMACError
- OpenSSL::Netscape
- OpenSSL::Netscape::SPKI
- OpenSSL::Netscape::SPKIError
- OpenSSL::OCSP
- OpenSSL::OCSP::BasicResponse
- OpenSSL::OCSP::CertificateId
- OpenSSL::OCSP::OCSPError
- OpenSSL::OCSP::Request
- OpenSSL::OCSP::Response
- OpenSSL::OpenSSLError
- OpenSSL::PKCS12
- OpenSSL::PKCS12::PKCS12Error
- OpenSSL::PKCS5
- OpenSSL::PKCS5::PKCS5Error
- OpenSSL::PKCS7
- OpenSSL::PKCS7::PKCS7Error
- OpenSSL::PKCS7::RecipientInfo
- OpenSSL::PKCS7::SignerInfo
- OpenSSL::PKey
- OpenSSL::PKey::DH
- OpenSSL::PKey::DHError
- OpenSSL::PKey::DSA
- OpenSSL::PKey::DSAError
- OpenSSL::PKey::EC
- OpenSSL::PKey::EC::Group
- OpenSSL::PKey::EC::Group::Error
- OpenSSL::PKey::EC::Point
- OpenSSL::PKey::EC::Point::Error
- OpenSSL::PKey::ECError
- OpenSSL::PKey::PKey
- OpenSSL::PKey::PKeyError
- OpenSSL::PKey::RSA
- OpenSSL::PKey::RSAError
- OpenSSL::Random
- OpenSSL::Random::RandomError
- OpenSSL::SSL
- OpenSSL::SSL::SSLContext
- OpenSSL::SSL::SSLContext::ExtConfig
- OpenSSL::SSL::SSLError
- OpenSSL::SSL::SSLErrorWaitReadable
- OpenSSL::SSL::SSLErrorWaitWritable
- OpenSSL::SSL::SSLServer
- OpenSSL::SSL::SSLSocket
- OpenSSL::SSL::SSLSocket::ExtConfig
- OpenSSL::SSL::Session
- OpenSSL::SSL::Session::SessionError
- OpenSSL::SSL::SocketForwarder
- OpenSSL::X509
- OpenSSL::X509::Attribute
- OpenSSL::X509::AttributeError
- OpenSSL::X509::CRL
- OpenSSL::X509::CRLError
- OpenSSL::X509::Certificate
- OpenSSL::X509::CertificateError
- OpenSSL::X509::Extension
- OpenSSL::X509::ExtensionError
- OpenSSL::X509::ExtensionFactory
- OpenSSL::X509::Name
- OpenSSL::X509::Name::RFC2253DN
- OpenSSL::X509::NameError
- OpenSSL::X509::Request
- OpenSSL::X509::RequestError
- OpenSSL::X509::Revoked
- OpenSSL::X509::RevokedError
- OpenSSL::X509::Store
- OpenSSL::X509::StoreContext
- OpenSSL::X509::StoreError
- unknown

No matching classes.

# OpenSSL::X509::Name::RFC2253DN

### Constants

AttributeType
AttributeValue
HexChar
HexPair
HexString
Pair
QuoteChar
Special
StringChar
TypeAndValue

### Public Instance Methods

expand_hexstring(str) click to toggle source

                   # File openssl/lib/openssl/x509.rb, line 90
    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 78
    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 97
    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 104
    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