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

**URL:** <https://www.ruby-forum.com/t/httpclient-sslconfig-uses-puts-a-a/172448>\
**Category:** Ruby\
**Created:** [July 21, 2009, 6:05pm UTC](https://www.ruby-forum.com/t/httpclient-sslconfig-uses-puts-a-a/172448 "2009-07-21T18:05:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [July 21, 2009, 6:05pm UTC](https://www.ruby-forum.com/t/httpclient-sslconfig-uses-puts-a-a/172448/1 "2009-07-21T18:05:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [July 21, 2009, 6:09pm UTC](https://www.ruby-forum.com/t/httpclient-sslconfig-uses-puts-a-a/172448/2 "2009-07-21T18:09:02Z")

</div>

2009/7/21 IÃ±aki Baz C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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

---

<div class="post-metadata">

**Author:** ![ISSSSaki\_Baz\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/51bf81/32.png) [@ISSSSaki\_Baz\_C](https://www.ruby-forum.com/u/ISSSSaki_Baz_C)\
**Post date:** [July 22, 2009, 4:15am UTC](https://www.ruby-forum.com/t/httpclient-sslconfig-uses-puts-a-a/172448/3 "2009-07-22T04:15:49Z")

</div>

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

> 2009/7/21 Iñaki Baz C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > 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.
