sample_verify_callback (HTTPClient::SSLConfig)

    # File lib/httpclient/ssl_config.rb, line 284
        def sample_verify_callback(is_ok, ctx)
          unless is_ok
            depth = ctx.error_depth
            code = ctx.error
            msg = ctx.error_string
            STDERR.puts "at depth #{depth} - #{code}: #{msg}" if $DEBUG
            return false
          end

          cert = ctx.current_cert
          self_signed = false
          ca = false
          pathlen = nil
          server_auth = true
          self_signed = (cert.subject.cmp(cert.issuer) == 0)

          # Check extensions whatever its criticality is. (sample)
          cert.extensions.each do |ex|
            case ex.oid
            when 'basicConstraints'
              /CA:(TRUE|FALSE), pathlen:(\d+)/ =~ ex.value
              ca = ($1 == 'TRUE')
              pathlen = $2.to_i
            when 'keyUsage'
              usage = ex.value.split(/\s*,\s*/)
              ca = usage.include?('Certificate Sign')
              server_auth = usage.include?('Key Encipherment')
            when 'extendedKeyUsage'
              usage = ex.value.split(/\s*,\s*/)
              server_auth = usage.include?('Netscape Server Gated Crypto')
            when 'nsCertType'
              usage = ex.value.split(/\s*,\s*/)
              ca = usage.include?('SSL CA')
              server_auth = usage.include?('SSL Server')
            end
          end

          if self_signed
            STDERR.puts 'self signing CA' if $DEBUG
            return true
          elsif ca
            STDERR.puts 'middle level CA' if $DEBUG
            return true
          elsif server_auth
            STDERR.puts 'for server authentication' if $DEBUG
            return true
          end

          return false
        end