Reputation: 1940
Hi all i'm trying to post the following from a controller in rails, however I constantly get the following error:
SSL_connect returned=1 errno=0 state=unknown state: sslv3 alert handshake failur
am I doing something wrong?
uri = URI.parse('https://devcheckout.psigate.com/HTMLPost/HTMLMessenger')
form_data = { 'StoreKey' => 'psigatecapturescard001010',
'CustomerRefNo' => 'Monday Evening Muay Thai Classes',
'UserID' => 'jsmith',
'SubTotal' => '34.00'
}
response = Net::HTTP.post_form(uri, form_data)
Upvotes: 0
Views: 259
Reputation: 495
check this, the accepted answer could maybe solve your problem:
Using Net::HTTP.get for an https url
also here are some informations about the error returned:
The errors seems to occur because your Net::HTTP instance use a SSL version (SSLv3) not supported by your server.
Try setting the ssl_version to 'TLSv1'
uri = URI.parse('https://devcheckout.psigate.com/HTMLPost/HTMLMessenger')
form_data = { 'StoreKey' => 'psigatecapturescard001010','CustomerRefNo' => 'Monday Evening Muay Thai Classes','UserID' => 'jsmith', 'SubTotal' => '34.00'}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.ssl_version = :TLSv1
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # read into this
@data = http.post(uri.request_uri, form_data.to_query)
tried it, works perfectly fine
Upvotes: 1
Reputation: 2037
Maybe you could do something like this:
uri = URI('https://devcheckout.psigate.com/HTMLPost/HTMLMessenger')
req = Net::HTTP::Post.new(uri)
req.use_ssl = true if uri.scheme == 'https'
req.set_form_data(
'StoreKey' => 'psigatecapturescard001010',
'CustomerRefNo' => 'Monday Evening Muay Thai Classes',
'UserID' => 'jsmith',
'SubTotal' => '34.00'
)
res = Net::HTTP.start(uri.hostname, uri.port) do |http|
http.request(req)
end
Upvotes: 1