Last Modified
2016-08-02 17:58:24 -0500
Requires
  • net/telnet
  • openssl

Description

begin

$RCSfile$ – SSL/TLS enhancement for Net::Telnet.

Info

'OpenSSL for Ruby 2' project
Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
All rights reserved.

Licence

This program is licenced under the same licence as Ruby.
(See the file 'LICENCE'.)

Version

$Id: telnets.rb 13657 2007-10-08 11:16:54Z gotoyuzo $

2001/11/06: Contiributed to Ruby/OpenSSL project.

class Net::Telnet

This class will initiate SSL/TLS session automaticaly if the server sent OPT_STARTTLS. Some options are added for SSL/TLS.

host = Net::Telnet::new({
         "Host"       => "localhost",
         "Port"       => "telnets",
         ## follows are new options.
         'CertFile'   => "user.crt",
         'KeyFile'    => "user.key",
         'CAFile'     => "/some/where/certs/casert.pem",
         'CAPath'     => "/some/where/caserts",
         'VerifyMode' => SSL::VERIFY_PEER,
         'VerifyCallback' => verify_proc
       })

Or, the new options ('Cert', 'Key' and 'CACert') are available from Michal Rokos's OpenSSL module.

cert_data = File.open("user.crt"){|io| io.read }
pkey_data = File.open("user.key"){|io| io.read }
cacert_data = File.open("your_ca.pem"){|io| io.read }
host = Net::Telnet::new({
         "Host"       => "localhost",
         "Port"       => "telnets",
         'Cert'       => OpenSSL::X509::Certificate.new(cert_data)
         'Key'        => OpenSSL::PKey::RSA.new(pkey_data)
         'CACert'     => OpenSSL::X509::Certificate.new(cacert_data)
         'CAFile'     => "/some/where/certs/casert.pem",
         'CAPath'     => "/some/where/caserts",
         'VerifyMode' => SSL::VERIFY_PEER,
         'VerifyCallback' => verify_proc
       })

This class is expected to be a superset of usual Net::Telnet.

end