OK, so through cross-mail to the Google EventMachine group, I found out what my problem was. Essentially, I tried to send data from the client to the server before the TLS handshake was completed, because I did not expect the ssl_handshake_completed callback to be called.
Here is the code I got to work, just in case anyone meets this post in the future. :)
Handler code for the server side:
require 'eventmachine' class ServerHandler < EM::Connection def post_init start_tls :private_key_file => 'server.key', :cert_chain_file => 'server.crt', :verify_peer => false end def receive_data(data) puts "Received data in server:
Client side handler code:
require 'eventmachine' class ClientHandler < EM::Connection def connection_completed start_tls end def receive_data(data) puts "Received data in client:
Code to start the server:
EventMachine.run do puts 'Starting server...' EventMachine.start_server('127.0.0.1', 45123, ServerHandler) end
Code to run the client:
EventMachine.run do puts 'Starting client...' EventMachine.connect('127.0.0.1', 45123, ClientHandler) end
Bryan source share