[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

http_access2 and SSL

Ed O'Loughlin

1/31/2005 4:16:00 PM

Hi,

I'm somewhat new to Ruby. I'm trying to force myself to use Ruby rather
than perl to write a simple script to get a form from a url and post
data using http_access2. It seems simple enough except that the site
uses https and has a self-signed cert.

My code is quite simple:

client = HTTPAccess2::Client.new(proxy)
# etc...
content = client.get_content(login_url)

I get the error in OpenSSL (see below). I had a look at the http_access2
code and it seems to provide for configuring OpenSSL (I want to tell it
not to verify certs) but it's not exposed in the constructor. I'm not
familiar enough with Ruby to decode some of the syntax, so I'm not sure
if there is a way of passing options to ssl.

Any help most appreciated before I fall back on bad habits (i.e., Perl).

Ed O'Loughlin

======
at depth 2 - 19: self signed certificate in certificate chain
d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:970:in `connect':
certificate verify failed (OpenSSL::SSL::SSLError)
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:970:in
`ssl_connect'
from
d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:1294:in `connect'
from
d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:1282:in `timeout'
from d:/ruby-1.8.1/lib/ruby/1.8/timeout.rb:55:in `timeout'
from
d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:1282:in `connect'
from
d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:1142:in `query'
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:864:in
`query'
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:414:in
`do_get_block'
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:358:in
`conn_request'
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:290:in
`request'
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:265:in
`get'
from d:/ruby-1.8.1/lib/ruby/site_ruby/1.8/http-access2.rb:240:in
`get_content'
from send_stuff.rb:16



1 Answer

NAKAMURA, Hiroshi

2/1/2005 7:38:00 AM

0

Hi,

Ed O'Loughlin wrote:
> I'm somewhat new to Ruby. I'm trying to force myself to use Ruby rather
> than perl to write a simple script to get a form from a url and post
> data using http_access2. It seems simple enough except that the site
> uses https and has a self-signed cert.
>
> My code is quite simple:
>
> client = HTTPAccess2::Client.new(proxy)
> # etc...
> content = client.get_content(login_url)
>
> I get the error in OpenSSL (see below). I had a look at the http_access2
> code and it seems to provide for configuring OpenSSL (I want to tell it
> not to verify certs) but it's not exposed in the constructor. I'm not
> familiar enough with Ruby to decode some of the syntax, so I'm not sure
> if there is a way of passing options to ssl.

You can tell a client not to verify the server with;

client.ssl_config.verify_mode = nil

Bear in mind that it's just an insecure and awkwardly slow connection.
:-) I recommend to set trusted CA certificate with;

client.cfg.set_trust_ca('ca_cert.pem')

FYI: here is a project site of http-access2:
http://rrr.jin.gr.jp/projects/ht...

Regards,
// NaHi