ruby-tls 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/EM-LICENSE +60 -60
- data/README.md +71 -69
- data/Rakefile +19 -19
- data/ext/Rakefile +18 -18
- data/ext/tls/page.cpp +102 -107
- data/ext/tls/page.h +61 -61
- data/ext/tls/ssl.cpp +587 -593
- data/ext/tls/ssl.h +129 -130
- data/lib/ruby-tls.rb +7 -7
- data/lib/ruby-tls/connection.rb +121 -121
- data/lib/ruby-tls/ext.rb +38 -32
- 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 +147 -147
- data/spec/verify_spec.rb +118 -118
- metadata +15 -16
data/spec/verify_spec.rb
CHANGED
@@ -1,118 +1,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
|
-
|
61
|
-
|
62
|
-
@client_data.
|
63
|
-
@server_data.
|
64
|
-
@cert_from_server.
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
it "should deny the connection" do
|
69
|
-
@server_data = []
|
70
|
-
@client_data = []
|
71
|
-
|
72
|
-
@client.close_cb do
|
73
|
-
@client_data << 'close'
|
74
|
-
@client_stop = true
|
75
|
-
end
|
76
|
-
@client.dispatch_cb do |data|
|
77
|
-
@client_data << data
|
78
|
-
end
|
79
|
-
@client.transmit_cb do |data|
|
80
|
-
if not @server_started
|
81
|
-
@server_started = true
|
82
|
-
@server.start(:server => true, :verify_peer => true)
|
83
|
-
end
|
84
|
-
@server.decrypt(data) unless @client_stop
|
85
|
-
end
|
86
|
-
@client.handshake_cb do
|
87
|
-
@client_data << 'ready'
|
88
|
-
end
|
89
|
-
|
90
|
-
@server.close_cb do
|
91
|
-
@server_data << 'close'
|
92
|
-
@server_stop = true
|
93
|
-
end
|
94
|
-
@server.dispatch_cb do |data|
|
95
|
-
@server_data << data
|
96
|
-
end
|
97
|
-
@server.transmit_cb do |data|
|
98
|
-
@client.decrypt(data) unless @server_stop
|
99
|
-
end
|
100
|
-
@server.handshake_cb do
|
101
|
-
@server_data << 'ready'
|
102
|
-
end
|
103
|
-
@server.verify_cb do |cert|
|
104
|
-
@server_data << 'verify'
|
105
|
-
@cert_from_server = cert
|
106
|
-
false
|
107
|
-
end
|
108
|
-
|
109
|
-
@client.start(:private_key_file => @dir + 'client.key', :cert_chain_file => @dir + 'client.crt')
|
110
|
-
|
111
|
-
|
112
|
-
@client_data.
|
113
|
-
@server_data.
|
114
|
-
@cert_from_server.
|
115
|
-
end
|
116
|
-
end
|
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
|
+
|
61
|
+
|
62
|
+
expect(@client_data).to eq(['ready'])
|
63
|
+
expect(@server_data).to eq(['verify', 'verify', 'verify', 'ready'])
|
64
|
+
expect(@cert_from_server).to eq(@cert_from_file)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "should deny the connection" do
|
69
|
+
@server_data = []
|
70
|
+
@client_data = []
|
71
|
+
|
72
|
+
@client.close_cb do
|
73
|
+
@client_data << 'close'
|
74
|
+
@client_stop = true
|
75
|
+
end
|
76
|
+
@client.dispatch_cb do |data|
|
77
|
+
@client_data << data
|
78
|
+
end
|
79
|
+
@client.transmit_cb do |data|
|
80
|
+
if not @server_started
|
81
|
+
@server_started = true
|
82
|
+
@server.start(:server => true, :verify_peer => true)
|
83
|
+
end
|
84
|
+
@server.decrypt(data) unless @client_stop
|
85
|
+
end
|
86
|
+
@client.handshake_cb do
|
87
|
+
@client_data << 'ready'
|
88
|
+
end
|
89
|
+
|
90
|
+
@server.close_cb do
|
91
|
+
@server_data << 'close'
|
92
|
+
@server_stop = true
|
93
|
+
end
|
94
|
+
@server.dispatch_cb do |data|
|
95
|
+
@server_data << data
|
96
|
+
end
|
97
|
+
@server.transmit_cb do |data|
|
98
|
+
@client.decrypt(data) unless @server_stop
|
99
|
+
end
|
100
|
+
@server.handshake_cb do
|
101
|
+
@server_data << 'ready'
|
102
|
+
end
|
103
|
+
@server.verify_cb do |cert|
|
104
|
+
@server_data << 'verify'
|
105
|
+
@cert_from_server = cert
|
106
|
+
false
|
107
|
+
end
|
108
|
+
|
109
|
+
@client.start(:private_key_file => @dir + 'client.key', :cert_chain_file => @dir + 'client.crt')
|
110
|
+
|
111
|
+
|
112
|
+
expect(@client_data).to eq([])
|
113
|
+
expect(@server_data).to eq(['verify', 'close', 'verify', 'close'])
|
114
|
+
expect(@cert_from_server).to eq(@cert_from_file)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
metadata
CHANGED
@@ -1,74 +1,73 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen von Takach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-compiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.0.2
|
20
20
|
type: :runtime
|
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: 0.0.2
|
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: '0'
|
34
34
|
type: :runtime
|
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: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
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: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
70
|
-
|
71
|
-
'
|
69
|
+
description: |2
|
70
|
+
Allows transport layers outside Ruby TCP be secured.
|
72
71
|
email:
|
73
72
|
- steve@cotag.me
|
74
73
|
executables: []
|
@@ -105,17 +104,17 @@ require_paths:
|
|
105
104
|
- lib
|
106
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
106
|
requirements:
|
108
|
-
- -
|
107
|
+
- - ">="
|
109
108
|
- !ruby/object:Gem::Version
|
110
109
|
version: '0'
|
111
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
111
|
requirements:
|
113
|
-
- -
|
112
|
+
- - ">="
|
114
113
|
- !ruby/object:Gem::Version
|
115
114
|
version: '0'
|
116
115
|
requirements: []
|
117
116
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.0.
|
117
|
+
rubygems_version: 2.0.3
|
119
118
|
signing_key:
|
120
119
|
specification_version: 4
|
121
120
|
summary: Abstract TLS for Ruby
|