Skip to content

Commit f83ff3a

Browse files
fixed webrick
Signed-off-by: Athishpranav2003 <[email protected]>
1 parent 1a78bbe commit f83ff3a

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

lib/fluent/plugin/out_http.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ def setup_http_option
270270
OpenSSL::SSL::VERIFY_PEER
271271
end
272272
opt[:ciphers] = @tls_ciphers
273-
opt[:min_version] = Fluent::TLS::DEFAULT_VERSION
274-
opt[:max_version] = @tls_version
273+
opt = Fluent::TLS.set_version_to_options(opt, @tls_version, nil, nil)
275274
end
276275

277276
opt

lib/fluent/tls.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ def set_version_to_context(ctx, version, min_version, max_version)
7676
ctx
7777
end
7878
module_function :set_version_to_context
79+
80+
def set_version_to_options(opt, version, min_version, max_version)
81+
if MIN_MAX_AVAILABLE
82+
case
83+
when min_version.nil? && max_version.nil?
84+
min_version = METHODS_MAP[version] || version
85+
max_version = METHODS_MAP[version] || version
86+
when min_version.nil? && max_version
87+
raise Fluent::ConfigError, "When you set max_version, must set min_version together"
88+
when min_version && max_version.nil?
89+
raise Fluent::ConfigError, "When you set min_version, must set max_version together"
90+
else
91+
min_version = METHODS_MAP[min_version] || min_version
92+
max_version = METHODS_MAP[max_version] || max_version
93+
end
94+
opt[:min_version] = min_version
95+
opt[:max_version] = max_version
96+
else
97+
opt[:ssl_version] = METHODS_MAP[version] || version
98+
end
99+
100+
opt
101+
end
102+
module_function :set_version_to_options
79103
end
80104
end
81105

test/plugin/test_out_http.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def server_config
501501
# WEBrick supports self-generated self-signed certificate
502502
config[:SSLEnable] = true
503503
config[:SSLCertName] = [["CN", WEBrick::Utils::getservername]]
504+
config[:SSLMaxVersion] = OpenSSL::SSL::TLS1_3_VERSION
504505
config
505506
end
506507

@@ -512,6 +513,7 @@ def test_write_with_https
512513
d = create_driver(%[
513514
endpoint https://127.0.0.1:#{server_port}/test
514515
tls_verify_mode none
516+
tls_version TLSv1_3
515517
ssl_timeout 2s
516518
])
517519
d.run(default_tag: 'test.http') do

0 commit comments

Comments
 (0)