Skip to content

Commit 34884be

Browse files
committed
support tls1.3
1 parent 042691e commit 34884be

File tree

7 files changed

+63
-38
lines changed

7 files changed

+63
-38
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#### 2.1.0
2+
3+
* Require Ruby 2.5
4+
* Allow TLS 1.3 (minimum remains TLS 1.2)
5+
6+
17
#### 2.0.0
28

39
* Require Ruby 2.4

Gemfile.lock

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
PATH
22
remote: .
33
specs:
4-
fluent-plugin-syslog-tls (2.0.0)
4+
fluent-plugin-syslog-tls (2.1.0.rc1)
55
fluentd (>= 0.14.0, < 2)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
addressable (2.8.0)
11-
public_suffix (>= 2.0.2, < 5.0)
12-
concurrent-ruby (1.1.9)
10+
addressable (2.8.1)
11+
public_suffix (>= 2.0.2, < 6.0)
12+
concurrent-ruby (1.1.10)
1313
cool.io (1.7.1)
1414
crack (0.4.5)
1515
rexml
1616
docile (1.4.0)
17-
fluentd (1.14.5)
17+
fluentd (1.15.3)
1818
bundler
1919
cool.io (>= 1.4.5, < 2.0.0)
2020
http_parser.rb (>= 0.5.1, < 0.9.0)
2121
msgpack (>= 1.3.1, < 2.0.0)
22-
serverengine (>= 2.2.5, < 3.0.0)
22+
serverengine (>= 2.3.0, < 3.0.0)
2323
sigdump (~> 0.2.2)
2424
strptime (>= 0.2.4, < 1.0.0)
2525
tzinfo (>= 1.0, < 3.0)
@@ -28,35 +28,35 @@ GEM
2828
yajl-ruby (~> 1.0)
2929
hashdiff (1.0.1)
3030
http_parser.rb (0.8.0)
31-
minitest (5.15.0)
31+
minitest (5.17.0)
3232
minitest-stub_any_instance (1.0.3)
33-
msgpack (1.4.5)
34-
power_assert (2.0.1)
35-
public_suffix (4.0.6)
33+
msgpack (1.6.0)
34+
power_assert (2.0.3)
35+
public_suffix (5.0.1)
3636
rake (13.0.6)
3737
rexml (3.2.5)
38-
serverengine (2.2.5)
38+
serverengine (2.3.1)
3939
sigdump (~> 0.2.2)
4040
sigdump (0.2.4)
41-
simplecov (0.21.2)
41+
simplecov (0.22.0)
4242
docile (~> 1.1)
4343
simplecov-html (~> 0.11)
4444
simplecov_json_formatter (~> 0.1)
4545
simplecov-html (0.12.3)
4646
simplecov_json_formatter (0.1.4)
4747
strptime (0.2.5)
48-
test-unit (3.5.3)
48+
test-unit (3.5.7)
4949
power_assert
50-
tzinfo (2.0.4)
50+
tzinfo (2.0.5)
5151
concurrent-ruby (~> 1.0)
52-
tzinfo-data (1.2021.5)
52+
tzinfo-data (1.2022.7)
5353
tzinfo (>= 1.0.0)
54-
webmock (3.14.0)
54+
webmock (3.18.1)
5555
addressable (>= 2.8.0)
5656
crack (>= 0.3.2)
5757
hashdiff (>= 0.4.0, < 2.0.0)
5858
webrick (1.7.0)
59-
yajl-ruby (1.4.1)
59+
yajl-ruby (1.4.3)
6060

6161
PLATFORMS
6262
ruby
@@ -71,4 +71,4 @@ DEPENDENCIES
7171
webmock (~> 3.0)
7272

7373
BUNDLED WITH
74-
2.2.22
74+
2.3.26

fluent-plugin-syslog-tls.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2016 Acquia, Inc.
2-
# Copyright 2016-2022 t.e.morgan.
2+
# Copyright 2016-2023 t.e.morgan.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
3030
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
3131
s.test_files = s.files.grep(%r{^(test|spec|features)/})
3232
s.require_paths = ['lib']
33-
s.required_ruby_version = '>= 2.4'
33+
s.required_ruby_version = '>= 2.5'
3434

3535
s.add_runtime_dependency 'fluentd', [">= 0.14.0", "< 2"]
3636

lib/syslog_tls/ssl_transport.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2016 Acquia, Inc.
2-
# Copyright 2016-2019 t.e.morgan.
2+
# Copyright 2016-2023 t.e.morgan.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ class SSLTransport
2929

3030
attr_writer :retries
3131

32-
def initialize(host, port, idle_timeout: nil, ca_cert: 'system', client_cert: nil, client_key: nil, verify_cert_name: true, ssl_version: :TLSv1_2, max_retries: 1)
32+
def initialize(host, port, idle_timeout: nil, ca_cert: 'system', client_cert: nil, client_key: nil, verify_cert_name: true, ssl_version: :TLS1_2, max_retries: 1)
3333
@host = host
3434
@port = port
3535
@idle_timeout = idle_timeout
@@ -96,7 +96,7 @@ def get_ssl_connection
9696

9797
ctx = OpenSSL::SSL::SSLContext.new
9898
ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
99-
ctx.ssl_version = ssl_version
99+
ctx.min_version = ssl_version
100100

101101
ctx.verify_hostname = verify_cert_name != false
102102

lib/syslog_tls/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
# limitations under the License.
1515

1616
module SyslogTls
17-
VERSION = '2.0.0'
17+
VERSION = '2.1.0.rc1'
1818
end

test/ssl.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
require 'openssl'
33

44
module SSLTestHelper
5-
def ssl_server
5+
def ssl_server(min_version: nil, max_version: nil)
66
@ssl_server ||= begin
77
tcp_server = TCPServer.new("localhost", 33000 + Random.rand(1000))
88
ssl_context = OpenSSL::SSL::SSLContext.new
99
ssl_context.cert = certificate
1010
ssl_context.key = rsa_key
11+
ssl_context.min_version = min_version if min_version
12+
ssl_context.max_version = max_version if max_version
1113
OpenSSL::SSL::SSLServer.new(tcp_server, ssl_context)
1214
end
1315
end

test/syslog_tls/test_ssl_transport.rb

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Copyright 2016 Acquia, Inc.
2-
# Copyright 2016 t.e.morgan.
2+
# Copyright 2016-2023 t.e.morgan.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
55
# you may not use this file except in compliance with the License.
@@ -20,19 +20,36 @@
2020
class SSLTransportTest < Test::Unit::TestCase
2121
include SSLTestHelper
2222

23-
def test_ok_connection
24-
server = ssl_server
25-
st = Thread.new {
26-
client = server.accept
27-
assert_equal "TESTTEST2\n", client.gets
28-
client.close
29-
}
30-
SyslogTls::SSLTransport.stub_any_instance(:get_ssl_connection, ssl_client) do
31-
t = SyslogTls::SSLTransport.new("localhost", server.addr[1], max_retries: 3)
32-
t.write("TEST")
33-
t.write("TEST2\n")
23+
# srvr-min srvr-max clnt-min should-raise?
24+
[ [:TLS1_2, :TLS1_2, :TLS1_2],
25+
[:TLS1_2, :TLS1_3, :TLS1_2],
26+
[:TLS1_3, :TLS1_3, :TLS1_2],
27+
[:TLS1_2, :TLS1_2, :TLS1_3, true],
28+
[:TLS1_2, :TLS1_3, :TLS1_3],
29+
[:TLS1_3, :TLS1_3, :TLS1_3],
30+
].each do |(server_min, server_max, client_min, should_raise)|
31+
define_method "test_#{server_min}-#{server_max}_server_#{client_min}_client" do
32+
Thread.report_on_exception = false
33+
blk = lambda do
34+
server = ssl_server(min_version: server_min, max_version: server_max)
35+
st = Thread.new {
36+
client = server.accept
37+
assert_equal "TESTTEST2\n", client.gets
38+
client.close
39+
}
40+
t = SyslogTls::SSLTransport.new("localhost", server.addr[1], ca_cert: false, ssl_version: client_min)
41+
t.write("TEST")
42+
t.write("TEST2\n")
43+
st.join
44+
end
45+
if should_raise
46+
assert_raises OpenSSL::SSL::SSLError, &blk
47+
else
48+
blk.call
49+
end
50+
ensure
51+
Thread.report_on_exception = true
3452
end
35-
st.join
3653
end
3754

3855
def test_retry

0 commit comments

Comments
 (0)