# Http-access2 and https. How to? (OpenSSL::X509::StoreError)

**URL:** <https://www.ruby-forum.com/t/http-access2-and-https-how-to-openssl-storeerror/82846>\
**Category:** Ruby\
**Created:** [January 21, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/http-access2-and-https-how-to-openssl-storeerror/82846 "2007-01-21T21:15:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_SSSgjfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@Peter\_SSSgjfc](https://www.ruby-forum.com/u/Peter_SSSgjfc)\
**Post date:** [January 21, 2007, 9:15pm UTC](https://www.ruby-forum.com/t/http-access2-and-https-how-to-openssl-storeerror/82846/1 "2007-01-21T21:15:53Z")

</div>

Hi,

The Gregory Houston blog has an entry about using http-access2 to  
talk with https websites:

> **[Using SSL with Ruby http-access2](http://ghouston.blogspot.com/2006/03/using-ssl-with-ruby-http-access2.html)**
>
> Expanding on my Ruby scripts, I wanted to download information from my yahoo account. Using Ruby to get HTTP is super easy. For example, t...

Here is the 4-line-demo he offers:

require ‘http-access2’  
client = HTTPAccess2::Client.new()  
client.ssl\_config.set\_trust\_ca(‘ca.cert’)  
puts client.get(‘[Yahoo](https://login.yahoo.com/config/login?)’).content

I fired up irb.  
I verified that I got the same initial error that he did.

I dont have IE so I used opera to export the key.  
It looks like it gave me a binary file.  
I wrote a bin\_to\_base64.rb script to transform the binary file:

#! /usr/bin/env ruby

require “base64”

binfile =  
‘/pt/w/browser\_certificates/equifax\_secure\_certificate\_authority.bin’  
b64file =  
‘/pt/w/browser\_certificates/equifax\_secure\_certificate\_authority.cer’

fhr = File.open binfile, “r”

bin\_s = “”

fhr.each {|l| bin\_s \<\< l}  
fhr.close

b64\_s = Base64.encode64 bin\_s

fhw = File.open b64file, “w”

fhw.write b64\_s  
fhw.close

It gave me this:

MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BAQUFADBOMQswCQYDVQQG  
EwJVUzEQM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= HTTPAccess2::Client.new()  
client.ssl\_config.set\_trust\_ca(“/pt/w/browser\_certificates/equifax\_secure\_certificate\_authority.cer”)  
puts client.get(‘[Yahoo](https://login.yahoo.com/config/login?)’).content

irb(main):011:0\> OpenSSL::X509::StoreError:  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb:532:in  
`add_file' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site_ruby/1.8/http-access2.rb:532:in `set\_trust\_ca’  
from (irb):11  
irb(main):012:0\> at depth 0 - 20: unable to get local issuer  
certificate  
OpenSSL::SSL::SSLError: certificate verify failed  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb:1001:in  
`connect' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site_ruby/1.8/http-access2.rb:1001:in `ssl\_connect’  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb:1363:in  
`connect' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/1.8/timeout.rb:56:in `timeout’  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/1.8/timeout.rb:76:in  
`timeout' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site_ruby/1.8/http-access2.rb:1351:in `connect’  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb:1209:in  
`query' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site_ruby/1.8/http-access2.rb:892:in `query’  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb:434:in  
`do_get_block' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site_ruby/1.8/http-access2.rb:370:in `conn\_request’  
from  
/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb:285:in  
`request' from /Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site_ruby/1.8/http-access2.rb:260:in `get’  
from (irb):12  
irb(main):013:0\> irb(main):014:0\*

I looked at the code near line 532 of

/Applications/Locomotive2/Bundles/standardRailsSept2006.locobundle/powerpc/lib/ruby/site\_ruby/1.8/http-access2.rb

I see:

def set\_trust\_ca(trust\_ca\_file\_or\_hashed\_dir)  
if FileTest.directory?(trust\_ca\_file\_or\_hashed\_dir)  
@cert\_store.add\_path(trust\_ca\_file\_or\_hashed\_dir)  
else  
@cert\_store.add\_file(trust\_ca\_file\_or\_hashed\_dir) # line 532  
end  
change\_notify  
end

I found the creation of @cert\_store about 1/2 page above line 532:

```
@cert_store = OpenSSL::X509::Store.new

```

So, I’m about to go nose around in the ruby OpenSSL code, demos,  
test-cases.

But, have any of you bumped into this issue?

Can you give me any hints on how to get http-acces2 talking to  
an https website?

Thanks.

---

<div class="post-metadata">

**Author:** ![Peter\_SSSgjfc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@Peter\_SSSgjfc](https://www.ruby-forum.com/u/Peter_SSSgjfc)\
**Post date:** [June 6, 2007, 5:13pm UTC](https://www.ruby-forum.com/t/http-access2-and-https-how-to-openssl-storeerror/82846/2 "2007-06-06T17:13:52Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi,

Sorry for the late response.

Peter S. [gjfc] wrote:

> I dont have IE so I used opera to export the key.  
> It looks like it gave me a binary file.

ruby -ropenssl -e ‘print  
OpenSSL::X509::Certificate.new(File.read(“ca.bin”)).to\_pem’ \> ca.pem

set ‘ca.pem’ as a trust anchor. You’ll know what is missing in your  
base64 format when you see the file generated (initial and last lines).

FYI: in openssl, we use ‘.cer’ for DER encoded binary format and ‘.pem’  
for base64 + envelope marker line format. Using ‘.cer’ filename for  
base64 format is misleading.

Regards,  
// NaHi

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.5 (Cygwin)

iQEVAwUBRmbOwh9L2jg5EEGlAQL3VQf8CJK47jHtNpdCOblxiEk6mlPTPAV5gpj9  
l480su+PYXopNWoJEwdRGtd3rZoFzYMQHdY5lS7PfyREL5XwdghmDAS+CZ/7vXPl  
/Ylc8jq8MGrNfG8LMXXf8QkmrlGYPJir5Ei4OmiWX9MinDBdi+Zc2mC6GQrSATxF  
+Bfz5SUf5JucvpHhiAsmxT6tA08m30J+mNhgQYf4DgmiZL3BGPPt1eyWNyHZ6Pnz  
IaSSQ97cr+ypIA0xSUCpLqpqjaoKrPkaMRz4ud35XoPaxtVAgZyu/3pJuyu+AqgC  
4SnWoCZySIr6oiwb2rlkd4WmcjHJf/AHmrH77F4V2DSvbfCV0wGOvQ==  
=TrA+  
-----END PGP SIGNATURE-----
