1#!/usr/bin/env ruby 2 3require 'drb' 4require 'drb/ssl' 5 6here = ARGV.shift || "drbssl://localhost:3456" 7 8class HelloWorld 9 include DRbUndumped 10 11 def hello(name) 12 "Hello, #{name}." 13 end 14end 15 16config = Hash.new 17config[:verbose] = true 18begin 19 data = open("sample.key"){|io| io.read } 20 config[:SSLPrivateKey] = OpenSSL::PKey::RSA.new(data) 21 data = open("sample.crt"){|io| io.read } 22 config[:SSLCertificate] = OpenSSL::X509::Certificate.new(data) 23rescue 24 $stderr.puts "Switching to use self-signed certificate" 25 config[:SSLCertName] = 26 [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ] 27end 28 29DRb.start_service(here, HelloWorld.new, config) 30puts DRb.uri 31DRb.thread.join 32