HTTPClient::SSLConfig uses "puts" ¿?¿?

Hi, I’m using HTTPClient which uses OpenSSL.
I’ve realized that HTTPClient includes a class SSLConfig which prints
to the standard and error output when verifying a SSL certificate,
i.e:

# Default callback for verification: only dumps error.
def default_verify_callback(is_ok, ctx)
  if $DEBUG
    puts "#{ is_ok ? 'ok' : 'ng' }: #{ctx.current_cert.subject}"
  end
  if !is_ok
    depth = ctx.error_depth
    code = ctx.error
    msg = ctx.error_string
    STDERR.puts "at depth #{depth} - #{code}: #{msg}"
  end
  is_ok
end

I set “http_client.ssl_config.verify_mode = 0” to avoid exceptions
when the SSL cert is not valid (expires, autosigned…) but, anyway,
the error is printed to the error output:

STDERR.puts “at depth #{depth} - #{code}: #{msg}”

This is really annoying. Why does a library writes to standar/error
output by itself? It shouldn’t occur!

Is there any ellegant way to avoid it without the need of rewritting
the methods?

Thanks.

2009/7/21 Iñaki Baz C. [email protected]:

This is really annoying. Why does a library writes to standar/error
output by itself? It shouldn’t occur!

It’s even worse, there are more “puts” into the module:

/usr/local/lib/ruby1.9/gems/1.9.1/gems/httpclient-2.1.5.2/lib$ grep -r
puts *
httpclient/ssl_config.rb: puts “#{ is_ok ? ‘ok’ : ‘ng’ }:
#{ctx.current_cert.subject}”
httpclient/ssl_config.rb: STDERR.puts “at depth #{depth} -
#{code}: #{msg}”
httpclient/ssl_config.rb: STDERR.puts “at depth #{depth} -
#{code}: #{msg}” if $DEBUG
httpclient/ssl_config.rb: STDERR.puts ‘self signing CA’ if $DEBUG
httpclient/ssl_config.rb: STDERR.puts ‘middle level CA’ if $DEBUG
httpclient/ssl_config.rb: STDERR.puts ‘for server
authentication’ if $DEBUG
httpclient/ssl_config.rb: STDERR.puts(“cacerts loading failed”)
httpclient.rb: puts “redirect to: #{newuri}” if $DEBUG
httpclient.rb: STDERR.puts(“could be a relative URI in location
header which is not recommended”)
httpclient.rb: STDERR.puts(“‘The field value consists of a single
absolute URI’ in HTTP spec”)
httpclient.rb: puts “redirect to: #{newuri}” if $DEBUG

On Jul 21, 2009, at 09:08, Iñaki Baz C. wrote:

2009/7/21 Iñaki Baz C. [email protected]:

This is really annoying. Why does a library writes to standar/error
output by itself? It shouldn’t occur!

It’s even worse, there are more “puts” into the module:

Please file a bug.