M
Mike Vastola
Hi Guys,
I'm having a weird (to me, at least) problem trying to connect to an SSL
socket using a custom protocol and read and send some data. Any help
would be greatly appreciated.
I'm getting the error:
/usr/lib/ruby/1.8/openssl/buffering.rb:35:in `sysread': Connection reset
by peer (Errno::ECONNRESET)
from /usr/lib/ruby/1.8/openssl/buffering.rb:35:in `fill_rbuff'
from /usr/lib/ruby/1.8/openssl/buffering.rb:67:in `read'
from ./display_pusher.rb:23:in `update_display'
from ./display_pusher.rb:44
My code is as follows:
-------------
#!/usr/bin/ruby
require 'openssl'
require 'socket'
require 'resolv'
class DisplayUpdater
def self.update_display(address, port, data)
sslCtx = OpenSSL::SSL::SSLContext.new()
sslCtx.ca_file = 'cacert.pem'
sslCtx.cert = OpenSSL::X509::Certificate.new(File.read("cert.pem"))
sslCtx.key = OpenSSL:Key::RSA.new(File.read("key.pem"))
sslCtx.verify_mode = OpenSSL::SSL::VERIFY_PEER
tcpSock = TCPSocket::new(address, port)
sslSock = OpenSSL::SSL::SSLSocket.new(tcpSock, sslCtx)
sslSock.sync_close = true
sslSock.connect
success = false
sslSock.write(data + "\n")
response = sslSock.read #**ERROR OCCURS HERE
#do some stuff with response here
puts "Success!"
sslSock.close
sslCtx.flush_sessions
return success
end
end
DisplayUpdater::update_display('127.0.0.1', 23, '--')
-----------
The server is running xinetd -> stunnel -> a custom c++ app, and I can
connect to it flawlessly from the same computer that's running ruby with
openssl s_client.
Any ideas what I'm doing wrong?
Thanks!
I'm having a weird (to me, at least) problem trying to connect to an SSL
socket using a custom protocol and read and send some data. Any help
would be greatly appreciated.
I'm getting the error:
/usr/lib/ruby/1.8/openssl/buffering.rb:35:in `sysread': Connection reset
by peer (Errno::ECONNRESET)
from /usr/lib/ruby/1.8/openssl/buffering.rb:35:in `fill_rbuff'
from /usr/lib/ruby/1.8/openssl/buffering.rb:67:in `read'
from ./display_pusher.rb:23:in `update_display'
from ./display_pusher.rb:44
My code is as follows:
-------------
#!/usr/bin/ruby
require 'openssl'
require 'socket'
require 'resolv'
class DisplayUpdater
def self.update_display(address, port, data)
sslCtx = OpenSSL::SSL::SSLContext.new()
sslCtx.ca_file = 'cacert.pem'
sslCtx.cert = OpenSSL::X509::Certificate.new(File.read("cert.pem"))
sslCtx.key = OpenSSL:Key::RSA.new(File.read("key.pem"))
sslCtx.verify_mode = OpenSSL::SSL::VERIFY_PEER
tcpSock = TCPSocket::new(address, port)
sslSock = OpenSSL::SSL::SSLSocket.new(tcpSock, sslCtx)
sslSock.sync_close = true
sslSock.connect
success = false
sslSock.write(data + "\n")
response = sslSock.read #**ERROR OCCURS HERE
#do some stuff with response here
puts "Success!"
sslSock.close
sslCtx.flush_sessions
return success
end
end
DisplayUpdater::update_display('127.0.0.1', 23, '--')
-----------
The server is running xinetd -> stunnel -> a custom c++ app, and I can
connect to it flawlessly from the same computer that's running ruby with
openssl s_client.
Any ideas what I'm doing wrong?
Thanks!