* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / sample / drb / drbssl_s.rb
blob4d96f591d4edf4b4d351a1180606cefe47988289
1 #!/usr/bin/env ruby
3 require 'drb'
4 require 'drb/ssl'
6 here = ARGV.shift || "drbssl://localhost:3456"
8 class HelloWorld
9   include DRbUndumped
11   def hello(name)
12     "Hello, #{name}."
13   end
14 end
16 config = Hash.new
17 config[:verbose] = true
18 begin
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)
23 rescue
24   $stderr.puts "Switching to use self-signed certificate"
25   config[:SSLCertName] =
26     [ ["C","JP"], ["O","Foo.DRuby.Org"], ["CN", "Sample"] ]
27 end
29 DRb.start_service(here, HelloWorld.new, config)
30 puts DRb.uri
31 DRb.thread.join