Server-to-Server SSL Connection

Hi everyone,

I need to make a server-to-server connection in my rails app to confirm
online credit card payments on the fly. When the confirm payment action
is run it calls a method in the ‘Order’ model object, the model attempts
to make an SSL connection to the payment gateway to confirm the payment
using the following code:

url: payment gateway domain name

path: relative path to confirmation script

params: string of HTTP params

http = Net::HTTP.new(url, 443)
http.use_ssl = true
resp, data = http.post(path, params)

The http.post() call returns the following error:

No such file or directory

/usr/lib/ruby/1.8/net/http.rb:586:in connect' /usr/lib/ruby/1.8/net/http.rb:586:inconnect’
/usr/lib/ruby/1.8/net/http.rb:553:in do_start' /usr/lib/ruby/1.8/net/http.rb:542:instart’
/usr/lib/ruby/1.8/net/http.rb:1032:in request' /usr/lib/ruby/1.8/net/http.rb:842:inpost’
#{RAILS_ROOT}/app/models/order.rb:59:in confirm_payment' #{RAILS_ROOT}/app/controllers/store_controller.rb:221:inpayment_approved’

Now, the code snippet above works 100% everywhere except when I try to
use it in a Rails app. The only way I can make this work in Rails is to
use nonsecure https rather than SSL, however the payment gateway
requires an SSL POST request to do the confirmation. The error is
obviously SSL specific, I have traced back through the Ruby code as far
as I can, any further entails tracing back through openssl.so. Has
anyone been ably to make this work?

Thanks,
Chris

Nobody has any insight on this one? Has no one needed to make a secure
server-to-server connection in a Rails app before?

On Jul 3, 2007, at 2:17 PM, ChrisN wrote:

Nobody has any insight on this one? Has no one needed to make a
secure
server-to-server connection in a Rails app before?

This works for me, but I don’t need to do a post.

require ‘socket’
require ‘openssl’

socket = TCPSocket.new(“www.url.net”)
ssl_context = OpenSSL::SSL::SSLContext.new()
unless ssl_context.verify_mode
warn “warning: peer certificate won’t be verified this session.”
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
sslsocket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)
sslsocket.sync_close = true
sslsocket.connect
sslsocket.puts(“some text”)

while line = sslsocket.gets
p line
end