ruby-tls 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/EM-LICENSE +60 -60
- data/README.md +71 -71
- data/Rakefile +19 -19
- data/ext/Rakefile +18 -18
- data/ext/tls/page.cpp +102 -102
- data/ext/tls/page.h +61 -61
- data/ext/tls/ssl.cpp +594 -587
- data/ext/tls/ssl.h +130 -129
- data/lib/ruby-tls.rb +7 -7
- data/lib/ruby-tls/connection.rb +124 -121
- data/lib/ruby-tls/ext.rb +39 -38
- data/lib/ruby-tls/version.rb +3 -3
- data/ruby-tls.gemspec +32 -32
- data/spec/client.crt +31 -31
- data/spec/client.key +51 -51
- data/spec/comms_spec.rb +156 -147
- data/spec/verify_spec.rb +120 -118
- metadata +34 -34
data/spec/verify_spec.rb
CHANGED
@@ -1,118 +1,120 @@
|
|
1
|
-
require 'ruby-tls'
|
2
|
-
|
3
|
-
|
4
|
-
describe RubyTls do
|
5
|
-
describe RubyTls::Connection do
|
6
|
-
before :each do
|
7
|
-
@client = RubyTls::Connection.new
|
8
|
-
@server = RubyTls::Connection.new
|
9
|
-
|
10
|
-
@server_started = false
|
11
|
-
@server_stop = false
|
12
|
-
@client_stop = false
|
13
|
-
|
14
|
-
@dir = File.dirname(File.expand_path(__FILE__)) + '/'
|
15
|
-
@cert_from_file = File.read(@dir + 'client.crt')
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should verify the peer" do
|
19
|
-
@server_data = []
|
20
|
-
@client_data = []
|
21
|
-
|
22
|
-
@client.close_cb do
|
23
|
-
@client_data << 'close'
|
24
|
-
@client_stop = true
|
25
|
-
end
|
26
|
-
@client.dispatch_cb do |data|
|
27
|
-
@client_data << data
|
28
|
-
end
|
29
|
-
@client.transmit_cb do |data|
|
30
|
-
if not @server_started
|
31
|
-
@server_started = true
|
32
|
-
@server.start(:server => true, :verify_peer => true)
|
33
|
-
end
|
34
|
-
@server.decrypt(data) unless @client_stop
|
35
|
-
end
|
36
|
-
@client.handshake_cb do
|
37
|
-
@client_data << 'ready'
|
38
|
-
end
|
39
|
-
|
40
|
-
@server.close_cb do
|
41
|
-
@server_data << 'close'
|
42
|
-
@server_stop = true
|
43
|
-
end
|
44
|
-
@server.dispatch_cb do |data|
|
45
|
-
@server_data << data
|
46
|
-
end
|
47
|
-
@server.transmit_cb do |data|
|
48
|
-
@client.decrypt(data) unless @server_stop
|
49
|
-
end
|
50
|
-
@server.handshake_cb do
|
51
|
-
@server_data << 'ready'
|
52
|
-
end
|
53
|
-
@server.verify_cb do |cert|
|
54
|
-
@server_data << 'verify'
|
55
|
-
@cert_from_server = cert
|
56
|
-
true
|
57
|
-
end
|
58
|
-
|
59
|
-
@client.start(:private_key_file => @dir + 'client.key', :cert_chain_file => @dir + 'client.crt')
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
expect(@
|
64
|
-
expect(@
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
@
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
@
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
@
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
expect(@
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
|
1
|
+
require 'ruby-tls'
|
2
|
+
|
3
|
+
|
4
|
+
describe RubyTls do
|
5
|
+
describe RubyTls::Connection do
|
6
|
+
before :each do
|
7
|
+
@client = RubyTls::Connection.new
|
8
|
+
@server = RubyTls::Connection.new
|
9
|
+
|
10
|
+
@server_started = false
|
11
|
+
@server_stop = false
|
12
|
+
@client_stop = false
|
13
|
+
|
14
|
+
@dir = File.dirname(File.expand_path(__FILE__)) + '/'
|
15
|
+
@cert_from_file = File.read(@dir + 'client.crt')
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should verify the peer" do
|
19
|
+
@server_data = []
|
20
|
+
@client_data = []
|
21
|
+
|
22
|
+
@client.close_cb do
|
23
|
+
@client_data << 'close'
|
24
|
+
@client_stop = true
|
25
|
+
end
|
26
|
+
@client.dispatch_cb do |data|
|
27
|
+
@client_data << data
|
28
|
+
end
|
29
|
+
@client.transmit_cb do |data|
|
30
|
+
if not @server_started
|
31
|
+
@server_started = true
|
32
|
+
@server.start(:server => true, :verify_peer => true)
|
33
|
+
end
|
34
|
+
@server.decrypt(data) unless @client_stop
|
35
|
+
end
|
36
|
+
@client.handshake_cb do
|
37
|
+
@client_data << 'ready'
|
38
|
+
end
|
39
|
+
|
40
|
+
@server.close_cb do
|
41
|
+
@server_data << 'close'
|
42
|
+
@server_stop = true
|
43
|
+
end
|
44
|
+
@server.dispatch_cb do |data|
|
45
|
+
@server_data << data
|
46
|
+
end
|
47
|
+
@server.transmit_cb do |data|
|
48
|
+
@client.decrypt(data) unless @server_stop
|
49
|
+
end
|
50
|
+
@server.handshake_cb do
|
51
|
+
@server_data << 'ready'
|
52
|
+
end
|
53
|
+
@server.verify_cb do |cert|
|
54
|
+
@server_data << 'verify'
|
55
|
+
@cert_from_server = cert
|
56
|
+
true
|
57
|
+
end
|
58
|
+
|
59
|
+
@client.start(:private_key_file => @dir + 'client.key', :cert_chain_file => @dir + 'client.crt')
|
60
|
+
@client.cleanup
|
61
|
+
@server.cleanup
|
62
|
+
|
63
|
+
expect(@client_data).to eq(['ready'])
|
64
|
+
expect(@server_data).to eq(['verify', 'verify', 'verify', 'ready'])
|
65
|
+
expect(@cert_from_server).to eq(@cert_from_file)
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
it "should deny the connection" do
|
70
|
+
@server_data = []
|
71
|
+
@client_data = []
|
72
|
+
|
73
|
+
@client.close_cb do
|
74
|
+
@client_data << 'close'
|
75
|
+
@client_stop = true
|
76
|
+
end
|
77
|
+
@client.dispatch_cb do |data|
|
78
|
+
@client_data << data
|
79
|
+
end
|
80
|
+
@client.transmit_cb do |data|
|
81
|
+
if not @server_started
|
82
|
+
@server_started = true
|
83
|
+
@server.start(:server => true, :verify_peer => true)
|
84
|
+
end
|
85
|
+
@server.decrypt(data) unless @client_stop
|
86
|
+
end
|
87
|
+
@client.handshake_cb do
|
88
|
+
@client_data << 'ready'
|
89
|
+
end
|
90
|
+
|
91
|
+
@server.close_cb do
|
92
|
+
@server_data << 'close'
|
93
|
+
@server_stop = true
|
94
|
+
end
|
95
|
+
@server.dispatch_cb do |data|
|
96
|
+
@server_data << data
|
97
|
+
end
|
98
|
+
@server.transmit_cb do |data|
|
99
|
+
@client.decrypt(data) unless @server_stop
|
100
|
+
end
|
101
|
+
@server.handshake_cb do
|
102
|
+
@server_data << 'ready'
|
103
|
+
end
|
104
|
+
@server.verify_cb do |cert|
|
105
|
+
@server_data << 'verify'
|
106
|
+
@cert_from_server = cert
|
107
|
+
false
|
108
|
+
end
|
109
|
+
|
110
|
+
@client.start(:private_key_file => @dir + 'client.key', :cert_chain_file => @dir + 'client.crt')
|
111
|
+
@client.cleanup
|
112
|
+
@server.cleanup
|
113
|
+
|
114
|
+
expect(@client_data).to eq([])
|
115
|
+
expect(@server_data).to eq(['verify', 'close', 'verify', 'close'])
|
116
|
+
expect(@cert_from_server).to eq(@cert_from_file)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-tls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-compiler
|
15
|
-
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.0.2
|
20
|
-
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
23
21
|
requirements:
|
24
|
-
- -
|
22
|
+
- - '>='
|
25
23
|
- !ruby/object:Gem::Version
|
26
24
|
version: 0.0.2
|
25
|
+
prerelease: false
|
26
|
+
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
29
34
|
requirement: !ruby/object:Gem::Requirement
|
30
35
|
requirements:
|
31
|
-
- -
|
36
|
+
- - '>='
|
32
37
|
- !ruby/object:Gem::Version
|
33
38
|
version: '0'
|
34
|
-
type: :runtime
|
35
39
|
prerelease: false
|
40
|
+
type: :runtime
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
36
43
|
version_requirements: !ruby/object:Gem::Requirement
|
37
44
|
requirements:
|
38
|
-
- -
|
45
|
+
- - '>='
|
39
46
|
- !ruby/object:Gem::Version
|
40
47
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rspec
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
44
49
|
requirements:
|
45
|
-
- -
|
50
|
+
- - '>='
|
46
51
|
- !ruby/object:Gem::Version
|
47
52
|
version: '0'
|
48
|
-
type: :development
|
49
53
|
prerelease: false
|
54
|
+
type: :development
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
50
57
|
version_requirements: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: yard
|
57
62
|
requirement: !ruby/object:Gem::Requirement
|
58
63
|
requirements:
|
59
|
-
- -
|
64
|
+
- - '>='
|
60
65
|
- !ruby/object:Gem::Version
|
61
66
|
version: '0'
|
62
|
-
type: :development
|
63
67
|
prerelease: false
|
64
|
-
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
type: :development
|
69
69
|
description: |2
|
70
70
|
Allows transport layers outside Ruby TCP be secured.
|
71
71
|
email:
|
@@ -76,10 +76,10 @@ extensions:
|
|
76
76
|
extra_rdoc_files:
|
77
77
|
- README.md
|
78
78
|
files:
|
79
|
+
- lib/ruby-tls.rb
|
79
80
|
- lib/ruby-tls/connection.rb
|
80
81
|
- lib/ruby-tls/ext.rb
|
81
82
|
- lib/ruby-tls/version.rb
|
82
|
-
- lib/ruby-tls.rb
|
83
83
|
- Rakefile
|
84
84
|
- ruby-tls.gemspec
|
85
85
|
- README.md
|
@@ -98,24 +98,24 @@ licenses:
|
|
98
98
|
- Ruby
|
99
99
|
- GPL
|
100
100
|
metadata: {}
|
101
|
-
post_install_message:
|
101
|
+
post_install_message:
|
102
102
|
rdoc_options: []
|
103
103
|
require_paths:
|
104
104
|
- lib
|
105
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - '>='
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
118
|
-
signing_key:
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.1.9
|
118
|
+
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Abstract TLS for Ruby
|
121
121
|
test_files:
|
@@ -123,4 +123,4 @@ test_files:
|
|
123
123
|
- spec/client.key
|
124
124
|
- spec/comms_spec.rb
|
125
125
|
- spec/verify_spec.rb
|
126
|
-
has_rdoc:
|
126
|
+
has_rdoc:
|