I'm trying to contribute with Croatian payment gatway, and ssl_post method is giving me a hard time. So, i generate my xml and use following code :
ssl_post( self.test_url, xml, { "Content-Type" => "application/xml" } )
and compiler greets me with following message:
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
Googled the problem, solution lies in path to certificates, or verification_mode( peer/none ). Next thing I do is create my own ssl_post method, to see if google got it right. Long story short, he got it. Short sketch:
def my_ssl( url, xml, headers )
uri = URI.parse( url )
https = Net::HTTP.new( uri.host, 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
# or this, both works
# https.verify_mode = OpenSSL::SSL::VERIFY_PEER
# https.ca_path ="/etc/ssl/certs"
request = Net::HTTP::Post.new( url )
request.body = xml
request.add_field( "Content-Type", "application/xml" )
return https.request( request )
end
Now that I know whats wrong, I want to use ssl_post even more, so I dig deeper. Figured out crutial variable is in module PostsData::ssl_strict. As much as I understand this portion of code, it's injecting variable accessor when module is included.
base.superclass_delegating_accessor :ssl_strict
base.ssl_strict = true
Can I somehow from within my Gateway class on runtime change it's value to false ?
Regards, Vedran