rubysl-openssl 1.0.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/ext/rubysl/openssl/.gitignore +3 -0
- data/ext/rubysl/openssl/deprecation.rb +21 -0
- data/ext/rubysl/openssl/extconf.rb +45 -32
- data/ext/rubysl/openssl/openssl_missing.c +20 -7
- data/ext/rubysl/openssl/openssl_missing.h +22 -15
- data/ext/rubysl/openssl/ossl.c +610 -61
- data/ext/rubysl/openssl/ossl.h +31 -17
- data/ext/rubysl/openssl/ossl_asn1.c +974 -183
- data/ext/rubysl/openssl/ossl_asn1.h +3 -3
- data/ext/rubysl/openssl/ossl_bio.c +4 -3
- data/ext/rubysl/openssl/ossl_bio.h +1 -1
- data/ext/rubysl/openssl/ossl_bn.c +32 -28
- data/ext/rubysl/openssl/ossl_bn.h +1 -1
- data/ext/rubysl/openssl/ossl_cipher.c +494 -93
- data/ext/rubysl/openssl/ossl_cipher.h +1 -1
- data/ext/rubysl/openssl/ossl_config.c +4 -5
- data/ext/rubysl/openssl/ossl_config.h +1 -1
- data/ext/rubysl/openssl/ossl_digest.c +206 -24
- data/ext/rubysl/openssl/ossl_digest.h +1 -1
- data/ext/rubysl/openssl/ossl_engine.c +48 -26
- data/ext/rubysl/openssl/ossl_engine.h +1 -1
- data/ext/rubysl/openssl/ossl_hmac.c +40 -38
- data/ext/rubysl/openssl/ossl_hmac.h +1 -1
- data/ext/rubysl/openssl/ossl_ns_spki.c +157 -25
- data/ext/rubysl/openssl/ossl_ns_spki.h +1 -1
- data/ext/rubysl/openssl/ossl_ocsp.c +57 -40
- data/ext/rubysl/openssl/ossl_ocsp.h +1 -1
- data/ext/rubysl/openssl/ossl_pkcs12.c +15 -13
- data/ext/rubysl/openssl/ossl_pkcs12.h +1 -1
- data/ext/rubysl/openssl/ossl_pkcs5.c +108 -18
- data/ext/rubysl/openssl/ossl_pkcs7.c +44 -37
- data/ext/rubysl/openssl/ossl_pkcs7.h +1 -1
- data/ext/rubysl/openssl/ossl_pkey.c +211 -15
- data/ext/rubysl/openssl/ossl_pkey.h +19 -9
- data/ext/rubysl/openssl/ossl_pkey_dh.c +180 -47
- data/ext/rubysl/openssl/ossl_pkey_dsa.c +184 -47
- data/ext/rubysl/openssl/ossl_pkey_ec.c +177 -93
- data/ext/rubysl/openssl/ossl_pkey_rsa.c +209 -102
- data/ext/rubysl/openssl/ossl_rand.c +15 -15
- data/ext/rubysl/openssl/ossl_rand.h +1 -1
- data/ext/rubysl/openssl/ossl_ssl.c +939 -192
- data/ext/rubysl/openssl/ossl_ssl.h +6 -6
- data/ext/rubysl/openssl/ossl_ssl_session.c +78 -62
- data/ext/rubysl/openssl/ossl_version.h +2 -2
- data/ext/rubysl/openssl/ossl_x509.c +1 -1
- data/ext/rubysl/openssl/ossl_x509.h +1 -1
- data/ext/rubysl/openssl/ossl_x509attr.c +20 -19
- data/ext/rubysl/openssl/ossl_x509cert.c +169 -67
- data/ext/rubysl/openssl/ossl_x509crl.c +41 -39
- data/ext/rubysl/openssl/ossl_x509ext.c +51 -38
- data/ext/rubysl/openssl/ossl_x509name.c +139 -29
- data/ext/rubysl/openssl/ossl_x509req.c +42 -40
- data/ext/rubysl/openssl/ossl_x509revoked.c +20 -20
- data/ext/rubysl/openssl/ossl_x509store.c +99 -47
- data/ext/rubysl/openssl/ruby_missing.h +3 -16
- data/lib/openssl/bn.rb +19 -19
- data/lib/openssl/buffering.rb +222 -14
- data/lib/openssl/cipher.rb +20 -20
- data/lib/openssl/config.rb +1 -4
- data/lib/openssl/digest.rb +47 -19
- data/lib/openssl/ssl.rb +197 -1
- data/lib/openssl/x509.rb +162 -1
- data/lib/rubysl/openssl.rb +4 -8
- data/lib/rubysl/openssl/version.rb +1 -1
- data/rubysl-openssl.gemspec +1 -2
- metadata +16 -34
- data/ext/rubysl/openssl/extconf.h +0 -50
- data/lib/openssl/net/ftptls.rb +0 -53
- data/lib/openssl/net/telnets.rb +0 -251
- data/lib/openssl/pkcs7.rb +0 -25
- data/lib/openssl/ssl-internal.rb +0 -187
- data/lib/openssl/x509-internal.rb +0 -153
data/lib/rubysl/openssl.rb
CHANGED
@@ -11,19 +11,15 @@
|
|
11
11
|
(See the file 'LICENCE'.)
|
12
12
|
|
13
13
|
= Version
|
14
|
-
$Id
|
14
|
+
$Id$
|
15
15
|
=end
|
16
16
|
|
17
|
-
require 'thread'
|
18
|
-
require "digest"
|
19
17
|
require 'openssl/openssl'
|
20
|
-
|
21
18
|
require 'openssl/bn'
|
22
19
|
require 'openssl/cipher'
|
23
20
|
require 'openssl/config'
|
24
21
|
require 'openssl/digest'
|
25
|
-
require 'openssl/
|
26
|
-
require 'openssl/ssl
|
27
|
-
require 'openssl/x509-internal'
|
22
|
+
require 'openssl/x509'
|
23
|
+
require 'openssl/ssl'
|
28
24
|
|
29
|
-
require
|
25
|
+
require "rubysl/openssl/version"
|
data/rubysl-openssl.gemspec
CHANGED
@@ -17,10 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.required_ruby_version = "~>
|
20
|
+
spec.required_ruby_version = "~> 2.0"
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
spec.add_development_dependency "mspec", "~> 1.5"
|
25
|
-
spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
|
26
25
|
end
|
metadata
CHANGED
@@ -1,71 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-openssl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rubysl-prettyprint
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.0'
|
69
55
|
description: Ruby standard library OpenSSL.
|
70
56
|
email:
|
71
57
|
- brixen@gmail.com
|
@@ -74,13 +60,14 @@ extensions:
|
|
74
60
|
- ext/rubysl/openssl/extconf.rb
|
75
61
|
extra_rdoc_files: []
|
76
62
|
files:
|
77
|
-
-
|
78
|
-
-
|
63
|
+
- .gitignore
|
64
|
+
- .travis.yml
|
79
65
|
- Gemfile
|
80
66
|
- LICENSE
|
81
67
|
- README.md
|
82
68
|
- Rakefile
|
83
|
-
- ext/rubysl/openssl
|
69
|
+
- ext/rubysl/openssl/.gitignore
|
70
|
+
- ext/rubysl/openssl/deprecation.rb
|
84
71
|
- ext/rubysl/openssl/extconf.rb
|
85
72
|
- ext/rubysl/openssl/openssl_missing.c
|
86
73
|
- ext/rubysl/openssl/openssl_missing.h
|
@@ -141,12 +128,7 @@ files:
|
|
141
128
|
- lib/openssl/cipher.rb
|
142
129
|
- lib/openssl/config.rb
|
143
130
|
- lib/openssl/digest.rb
|
144
|
-
- lib/openssl/net/ftptls.rb
|
145
|
-
- lib/openssl/net/telnets.rb
|
146
|
-
- lib/openssl/pkcs7.rb
|
147
|
-
- lib/openssl/ssl-internal.rb
|
148
131
|
- lib/openssl/ssl.rb
|
149
|
-
- lib/openssl/x509-internal.rb
|
150
132
|
- lib/openssl/x509.rb
|
151
133
|
- lib/rubysl/openssl.rb
|
152
134
|
- lib/rubysl/openssl/version.rb
|
@@ -170,17 +152,17 @@ require_paths:
|
|
170
152
|
- lib
|
171
153
|
required_ruby_version: !ruby/object:Gem::Requirement
|
172
154
|
requirements:
|
173
|
-
- -
|
155
|
+
- - ~>
|
174
156
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
157
|
+
version: '2.0'
|
176
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
159
|
requirements:
|
178
|
-
- -
|
160
|
+
- - '>='
|
179
161
|
- !ruby/object:Gem::Version
|
180
162
|
version: '0'
|
181
163
|
requirements: []
|
182
164
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.0.7
|
184
166
|
signing_key:
|
185
167
|
specification_version: 4
|
186
168
|
summary: Ruby standard library OpenSSL.
|
@@ -1,50 +0,0 @@
|
|
1
|
-
#ifndef EXTCONF_H
|
2
|
-
#define EXTCONF_H
|
3
|
-
#define HAVE_ASSERT_H 1
|
4
|
-
#define HAVE_OPENSSL_SSL_H 1
|
5
|
-
#define HAVE_OPENSSL_CONF_API_H 1
|
6
|
-
#define HAVE_ERR_PEEK_LAST_ERROR 1
|
7
|
-
#define HAVE_BN_MOD_ADD 1
|
8
|
-
#define HAVE_BN_MOD_SQR 1
|
9
|
-
#define HAVE_BN_MOD_SUB 1
|
10
|
-
#define HAVE_BN_PSEUDO_RAND_RANGE 1
|
11
|
-
#define HAVE_BN_RAND_RANGE 1
|
12
|
-
#define HAVE_CONF_GET1_DEFAULT_CONFIG_FILE 1
|
13
|
-
#define HAVE_EVP_CIPHER_CTX_SET_PADDING 1
|
14
|
-
#define HAVE_EVP_CIPHERFINAL_EX 1
|
15
|
-
#define HAVE_EVP_CIPHERINIT_EX 1
|
16
|
-
#define HAVE_EVP_DIGESTFINAL_EX 1
|
17
|
-
#define HAVE_EVP_DIGESTINIT_EX 1
|
18
|
-
#define HAVE_EVP_MD_CTX_CLEANUP 1
|
19
|
-
#define HAVE_EVP_MD_CTX_CREATE 1
|
20
|
-
#define HAVE_EVP_MD_CTX_DESTROY 1
|
21
|
-
#define HAVE_EVP_MD_CTX_INIT 1
|
22
|
-
#define HAVE_HMAC_CTX_CLEANUP 1
|
23
|
-
#define HAVE_HMAC_CTX_INIT 1
|
24
|
-
#define HAVE_PEM_DEF_CALLBACK 1
|
25
|
-
#define HAVE_PKCS5_PBKDF2_HMAC_SHA1 1
|
26
|
-
#define HAVE_X509V3_SET_NCONF 1
|
27
|
-
#define HAVE_X509V3_EXT_NCONF_NID 1
|
28
|
-
#define HAVE_X509_CRL_ADD0_REVOKED 1
|
29
|
-
#define HAVE_X509_CRL_SET_ISSUER_NAME 1
|
30
|
-
#define HAVE_X509_CRL_SET_VERSION 1
|
31
|
-
#define HAVE_X509_CRL_SORT 1
|
32
|
-
#define HAVE_OBJ_NAME_DO_ALL_SORTED 1
|
33
|
-
#define HAVE_SSL_SESSION_GET_ID 1
|
34
|
-
#define HAVE_OPENSSL_CLEANSE 1
|
35
|
-
#define HAVE_VA_ARGS_MACRO 1
|
36
|
-
#define HAVE_SSLV2_METHOD 1
|
37
|
-
#define HAVE_SSLV2_SERVER_METHOD 1
|
38
|
-
#define HAVE_SSLV2_CLIENT_METHOD 1
|
39
|
-
#define HAVE_SSL_SET_TLSEXT_HOST_NAME 1
|
40
|
-
#define HAVE_OPENSSL_ENGINE_H 1
|
41
|
-
#define HAVE_ENGINE_ADD 1
|
42
|
-
#define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1
|
43
|
-
#define HAVE_ENGINE_GET_DIGEST 1
|
44
|
-
#define HAVE_ENGINE_GET_CIPHER 1
|
45
|
-
#define HAVE_ENGINE_CLEANUP 1
|
46
|
-
#define HAVE_OPENSSL_OCSP_H 1
|
47
|
-
#define HAVE_ST_FLAGS 1
|
48
|
-
#define HAVE_ST_ENGINE 1
|
49
|
-
#define HAVE_ST_SINGLE 1
|
50
|
-
#endif
|
data/lib/openssl/net/ftptls.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
|
3
|
-
|
4
|
-
= Info
|
5
|
-
'OpenSSL for Ruby 2' project
|
6
|
-
Copyright (C) 2003 Blaz Grilc <farmer@gmx.co.uk>
|
7
|
-
All rights reserved.
|
8
|
-
|
9
|
-
= Licence
|
10
|
-
This program is licenced under the same licence as Ruby.
|
11
|
-
(See the file 'LICENCE'.)
|
12
|
-
|
13
|
-
= Requirements
|
14
|
-
|
15
|
-
= Version
|
16
|
-
$Id: ftptls.rb 13657 2007-10-08 11:16:54Z gotoyuzo $
|
17
|
-
|
18
|
-
= Notes
|
19
|
-
Tested on FreeBSD 5-CURRENT and 4-STABLE
|
20
|
-
- ruby 1.6.8 (2003-01-17) [i386-freebsd5]
|
21
|
-
- OpenSSL 0.9.7a Feb 19 2003
|
22
|
-
- ruby-openssl-0.2.0.p0
|
23
|
-
tested on ftp server: glftpd 1.30
|
24
|
-
=end
|
25
|
-
|
26
|
-
require 'socket'
|
27
|
-
require 'openssl'
|
28
|
-
require 'net/ftp'
|
29
|
-
|
30
|
-
module Net
|
31
|
-
class FTPTLS < FTP
|
32
|
-
def connect(host, port=FTP_PORT)
|
33
|
-
@hostname = host
|
34
|
-
super
|
35
|
-
end
|
36
|
-
|
37
|
-
def login(user = "anonymous", passwd = nil, acct = nil)
|
38
|
-
store = OpenSSL::X509::Store.new
|
39
|
-
store.set_default_paths
|
40
|
-
ctx = OpenSSL::SSL::SSLContext.new('SSLv23')
|
41
|
-
ctx.cert_store = store
|
42
|
-
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
43
|
-
ctx.key = nil
|
44
|
-
ctx.cert = nil
|
45
|
-
voidcmd("AUTH TLS")
|
46
|
-
@sock = OpenSSL::SSL::SSLSocket.new(@sock, ctx)
|
47
|
-
@sock.connect
|
48
|
-
@sock.post_connection_check(@hostname)
|
49
|
-
super(user, passwd, acct)
|
50
|
-
voidcmd("PBSZ 0")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/openssl/net/telnets.rb
DELETED
@@ -1,251 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
= $RCSfile$ -- SSL/TLS enhancement for Net::Telnet.
|
3
|
-
|
4
|
-
= Info
|
5
|
-
'OpenSSL for Ruby 2' project
|
6
|
-
Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
|
7
|
-
All rights reserved.
|
8
|
-
|
9
|
-
= Licence
|
10
|
-
This program is licenced under the same licence as Ruby.
|
11
|
-
(See the file 'LICENCE'.)
|
12
|
-
|
13
|
-
= Version
|
14
|
-
$Id: telnets.rb 13657 2007-10-08 11:16:54Z gotoyuzo $
|
15
|
-
|
16
|
-
2001/11/06: Contiributed to Ruby/OpenSSL project.
|
17
|
-
|
18
|
-
== class Net::Telnet
|
19
|
-
|
20
|
-
This class will initiate SSL/TLS session automaticaly if the server
|
21
|
-
sent OPT_STARTTLS. Some options are added for SSL/TLS.
|
22
|
-
|
23
|
-
host = Net::Telnet::new({
|
24
|
-
"Host" => "localhost",
|
25
|
-
"Port" => "telnets",
|
26
|
-
## follows are new options.
|
27
|
-
'CertFile' => "user.crt",
|
28
|
-
'KeyFile' => "user.key",
|
29
|
-
'CAFile' => "/some/where/certs/casert.pem",
|
30
|
-
'CAPath' => "/some/where/caserts",
|
31
|
-
'VerifyMode' => SSL::VERIFY_PEER,
|
32
|
-
'VerifyCallback' => verify_proc
|
33
|
-
})
|
34
|
-
|
35
|
-
Or, the new options ('Cert', 'Key' and 'CACert') are available from
|
36
|
-
Michal Rokos's OpenSSL module.
|
37
|
-
|
38
|
-
cert_data = File.open("user.crt"){|io| io.read }
|
39
|
-
pkey_data = File.open("user.key"){|io| io.read }
|
40
|
-
cacert_data = File.open("your_ca.pem"){|io| io.read }
|
41
|
-
host = Net::Telnet::new({
|
42
|
-
"Host" => "localhost",
|
43
|
-
"Port" => "telnets",
|
44
|
-
'Cert' => OpenSSL::X509::Certificate.new(cert_data)
|
45
|
-
'Key' => OpenSSL::PKey::RSA.new(pkey_data)
|
46
|
-
'CACert' => OpenSSL::X509::Certificate.new(cacert_data)
|
47
|
-
'CAFile' => "/some/where/certs/casert.pem",
|
48
|
-
'CAPath' => "/some/where/caserts",
|
49
|
-
'VerifyMode' => SSL::VERIFY_PEER,
|
50
|
-
'VerifyCallback' => verify_proc
|
51
|
-
})
|
52
|
-
|
53
|
-
This class is expected to be a superset of usual Net::Telnet.
|
54
|
-
=end
|
55
|
-
|
56
|
-
require "net/telnet"
|
57
|
-
require "openssl"
|
58
|
-
|
59
|
-
module Net
|
60
|
-
class Telnet
|
61
|
-
attr_reader :ssl
|
62
|
-
|
63
|
-
OPT_STARTTLS = 46.chr # "\056" # "\x2e" # Start TLS
|
64
|
-
TLS_FOLLOWS = 1.chr # "\001" # "\x01" # FOLLOWS (for STARTTLS)
|
65
|
-
|
66
|
-
alias preprocess_orig preprocess
|
67
|
-
|
68
|
-
def ssl?; @ssl; end
|
69
|
-
|
70
|
-
def preprocess(string)
|
71
|
-
# combine CR+NULL into CR
|
72
|
-
string = string.gsub(/#{CR}#{NULL}/no, CR) if @options["Telnetmode"]
|
73
|
-
|
74
|
-
# combine EOL into "\n"
|
75
|
-
string = string.gsub(/#{EOL}/no, "\n") unless @options["Binmode"]
|
76
|
-
|
77
|
-
string.gsub(/#{IAC}(
|
78
|
-
[#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]|
|
79
|
-
[#{DO}#{DONT}#{WILL}#{WONT}][#{OPT_BINARY}-#{OPT_EXOPL}]|
|
80
|
-
#{SB}[#{OPT_BINARY}-#{OPT_EXOPL}]
|
81
|
-
(#{IAC}#{IAC}|[^#{IAC}])+#{IAC}#{SE}
|
82
|
-
)/xno) do
|
83
|
-
if IAC == $1 # handle escaped IAC characters
|
84
|
-
IAC
|
85
|
-
elsif AYT == $1 # respond to "IAC AYT" (are you there)
|
86
|
-
self.write("nobody here but us pigeons" + EOL)
|
87
|
-
''
|
88
|
-
elsif DO[0] == $1[0] # respond to "IAC DO x"
|
89
|
-
if OPT_BINARY[0] == $1[1]
|
90
|
-
@telnet_option["BINARY"] = true
|
91
|
-
self.write(IAC + WILL + OPT_BINARY)
|
92
|
-
elsif OPT_STARTTLS[0] == $1[1]
|
93
|
-
self.write(IAC + WILL + OPT_STARTTLS)
|
94
|
-
self.write(IAC + SB + OPT_STARTTLS + TLS_FOLLOWS + IAC + SE)
|
95
|
-
else
|
96
|
-
self.write(IAC + WONT + $1[1..1])
|
97
|
-
end
|
98
|
-
''
|
99
|
-
elsif DONT[0] == $1[0] # respond to "IAC DON'T x" with "IAC WON'T x"
|
100
|
-
self.write(IAC + WONT + $1[1..1])
|
101
|
-
''
|
102
|
-
elsif WILL[0] == $1[0] # respond to "IAC WILL x"
|
103
|
-
if OPT_BINARY[0] == $1[1]
|
104
|
-
self.write(IAC + DO + OPT_BINARY)
|
105
|
-
elsif OPT_ECHO[0] == $1[1]
|
106
|
-
self.write(IAC + DO + OPT_ECHO)
|
107
|
-
elsif OPT_SGA[0] == $1[1]
|
108
|
-
@telnet_option["SGA"] = true
|
109
|
-
self.write(IAC + DO + OPT_SGA)
|
110
|
-
else
|
111
|
-
self.write(IAC + DONT + $1[1..1])
|
112
|
-
end
|
113
|
-
''
|
114
|
-
elsif WONT[0] == $1[0] # respond to "IAC WON'T x"
|
115
|
-
if OPT_ECHO[0] == $1[1]
|
116
|
-
self.write(IAC + DONT + OPT_ECHO)
|
117
|
-
elsif OPT_SGA[0] == $1[1]
|
118
|
-
@telnet_option["SGA"] = false
|
119
|
-
self.write(IAC + DONT + OPT_SGA)
|
120
|
-
else
|
121
|
-
self.write(IAC + DONT + $1[1..1])
|
122
|
-
end
|
123
|
-
''
|
124
|
-
elsif SB[0] == $1[0] # respond to "IAC SB xxx IAC SE"
|
125
|
-
if OPT_STARTTLS[0] == $1[1] && TLS_FOLLOWS[0] == $2[0]
|
126
|
-
@sock = OpenSSL::SSL::SSLSocket.new(@sock)
|
127
|
-
@sock.cert = @options['Cert'] unless @sock.cert
|
128
|
-
@sock.key = @options['Key'] unless @sock.key
|
129
|
-
@sock.ca_cert = @options['CACert']
|
130
|
-
@sock.ca_file = @options['CAFile']
|
131
|
-
@sock.ca_path = @options['CAPath']
|
132
|
-
@sock.timeout = @options['Timeout']
|
133
|
-
@sock.verify_mode = @options['VerifyMode']
|
134
|
-
@sock.verify_callback = @options['VerifyCallback']
|
135
|
-
@sock.verify_depth = @options['VerifyDepth']
|
136
|
-
@sock.connect
|
137
|
-
if @options['VerifyMode'] != OpenSSL::SSL::VERIFY_NONE
|
138
|
-
@sock.post_connection_check(@options['Host'])
|
139
|
-
end
|
140
|
-
@ssl = true
|
141
|
-
end
|
142
|
-
''
|
143
|
-
else
|
144
|
-
''
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end # preprocess
|
148
|
-
|
149
|
-
alias waitfor_org waitfor
|
150
|
-
|
151
|
-
def waitfor(options)
|
152
|
-
time_out = @options["Timeout"]
|
153
|
-
waittime = @options["Waittime"]
|
154
|
-
|
155
|
-
if options.kind_of?(Hash)
|
156
|
-
prompt = if options.has_key?("Match")
|
157
|
-
options["Match"]
|
158
|
-
elsif options.has_key?("Prompt")
|
159
|
-
options["Prompt"]
|
160
|
-
elsif options.has_key?("String")
|
161
|
-
Regexp.new( Regexp.quote(options["String"]) )
|
162
|
-
end
|
163
|
-
time_out = options["Timeout"] if options.has_key?("Timeout")
|
164
|
-
waittime = options["Waittime"] if options.has_key?("Waittime")
|
165
|
-
else
|
166
|
-
prompt = options
|
167
|
-
end
|
168
|
-
|
169
|
-
if time_out == false
|
170
|
-
time_out = nil
|
171
|
-
end
|
172
|
-
|
173
|
-
line = ''
|
174
|
-
buf = ''
|
175
|
-
@rest = '' unless @rest
|
176
|
-
|
177
|
-
until(prompt === line and not IO::select([@sock], nil, nil, waittime))
|
178
|
-
unless IO::select([@sock], nil, nil, time_out)
|
179
|
-
raise TimeoutError, "timed-out; wait for the next data"
|
180
|
-
end
|
181
|
-
begin
|
182
|
-
c = @rest + @sock.sysread(1024 * 1024)
|
183
|
-
@dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
|
184
|
-
if @options["Telnetmode"]
|
185
|
-
pos = 0
|
186
|
-
catch(:next){
|
187
|
-
while true
|
188
|
-
case c[pos]
|
189
|
-
when IAC[0]
|
190
|
-
case c[pos+1]
|
191
|
-
when DO[0], DONT[0], WILL[0], WONT[0]
|
192
|
-
throw :next unless c[pos+2]
|
193
|
-
pos += 3
|
194
|
-
when SB[0]
|
195
|
-
ret = detect_sub_negotiation(c, pos)
|
196
|
-
throw :next unless ret
|
197
|
-
pos = ret
|
198
|
-
when nil
|
199
|
-
throw :next
|
200
|
-
else
|
201
|
-
pos += 2
|
202
|
-
end
|
203
|
-
when nil
|
204
|
-
throw :next
|
205
|
-
else
|
206
|
-
pos += 1
|
207
|
-
end
|
208
|
-
end
|
209
|
-
}
|
210
|
-
|
211
|
-
buf = preprocess(c[0...pos])
|
212
|
-
@rest = c[pos..-1]
|
213
|
-
end
|
214
|
-
@log.print(buf) if @options.has_key?("Output_log")
|
215
|
-
line.concat(buf)
|
216
|
-
yield buf if block_given?
|
217
|
-
rescue EOFError # End of file reached
|
218
|
-
if line == ''
|
219
|
-
line = nil
|
220
|
-
yield nil if block_given?
|
221
|
-
end
|
222
|
-
break
|
223
|
-
end
|
224
|
-
end
|
225
|
-
line
|
226
|
-
end
|
227
|
-
|
228
|
-
private
|
229
|
-
|
230
|
-
def detect_sub_negotiation(data, pos)
|
231
|
-
return nil if data.length < pos+6 # IAC SB x param IAC SE
|
232
|
-
pos += 3
|
233
|
-
while true
|
234
|
-
case data[pos]
|
235
|
-
when IAC[0]
|
236
|
-
if data[pos+1] == SE[0]
|
237
|
-
pos += 2
|
238
|
-
return pos
|
239
|
-
else
|
240
|
-
pos += 2
|
241
|
-
end
|
242
|
-
when nil
|
243
|
-
return nil
|
244
|
-
else
|
245
|
-
pos += 1
|
246
|
-
end
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
end
|
251
|
-
end
|