Skip to content

Commit aad460b

Browse files
yaauiemashhurs
andauthored
ssl: use NoopHostnameVerifier when ssl_verification_mode is 'none' (#165)
* ssl: use NoopHostnameVerifier when ssl_verification_mode is 'none' Fixes: #164 * Unit and integration tests added for the where SSL verification mode is disabled over SSL connection. (#168) --------- Co-authored-by: Mashhur <[email protected]>
1 parent e77de70 commit aad460b

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.1.15
2+
- Fixes the connection failure where SSL verification mode is disabled over SSL connection [#165](https://github.com/elastic/logstash-filter-elastic_integration/pull/165)
3+
14
## 0.1.14
25
- Fix: register available PainlessExtension-s, resolving an issue where the pipelines for some integrations would fail to compile [#162](https://github.com/elastic/logstash-filter-elastic_integration/pull/162)
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.14
1+
0.1.15

spec/integration/elastic_integration_spec.rb

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"password" => integ_user_password,
3030
"ssl_enabled" => true,
3131
"ssl_verification_mode" => "certificate",
32-
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt",
3332
"ssl_certificate" => "spec/fixtures/test_certs/client_from_root.crt",
3433
"ssl_key" => "spec/fixtures/test_certs/client_from_root.key.pkcs8",
3534
"ssl_key_passphrase" => "12345678"
@@ -115,6 +114,11 @@
115114
end
116115

117116
context '#pipeline execution' do
117+
let(:settings) {
118+
super().merge(
119+
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
120+
)
121+
}
118122

119123
before(:each) do
120124
subject.register
@@ -1133,6 +1137,12 @@ def path; @path; end
11331137
end
11341138

11351139
context '#multi-pipeline execution' do
1140+
let(:settings) {
1141+
super().merge(
1142+
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
1143+
)
1144+
}
1145+
11361146
before(:each) do
11371147
subject.register
11381148
end
@@ -1168,6 +1178,11 @@ def path; @path; end
11681178
end
11691179

11701180
context '#failures' do
1181+
let(:settings) {
1182+
super().merge(
1183+
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
1184+
)
1185+
}
11711186

11721187
before(:each) do
11731188
subject.register
@@ -1227,6 +1242,11 @@ def path; @path; end
12271242
end
12281243

12291244
context '#privileges' do
1245+
let(:settings) {
1246+
super().merge(
1247+
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
1248+
)
1249+
}
12301250
# a user who doesn't have pipeline privileges
12311251
let(:integ_user_name) {
12321252
"ls_integration_tests_user"
@@ -1323,6 +1343,11 @@ def path; @path; end
13231343
end
13241344

13251345
context '#emulating real scenario' do
1346+
let(:settings) {
1347+
super().merge(
1348+
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
1349+
)
1350+
}
13261351
let(:index_settings) {
13271352
{
13281353
"type" => "log",
@@ -1406,7 +1431,8 @@ def path; @path; end
14061431
let(:settings) {
14071432
super().merge(
14081433
# certificate is signed with localhost/127.0.0.1, should complain
1409-
"ssl_verification_mode" => "full"
1434+
"ssl_verification_mode" => "full",
1435+
"ssl_certificate_authorities" => "spec/fixtures/test_certs/root.crt"
14101436
)
14111437
}
14121438

@@ -1428,6 +1454,30 @@ def path; @path; end
14281454
end)
14291455
end
14301456
end
1457+
1458+
describe 'when SSL enabled and verification is disabled' do
1459+
1460+
let(:settings) {
1461+
super().merge(
1462+
"ssl_enabled" => true,
1463+
"ssl_verification_mode" => "none"
1464+
)
1465+
}
1466+
1467+
# just need to fill the params, we don't/can't send any request to ES
1468+
let(:pipeline_processor) {
1469+
'{
1470+
"dissect": {
1471+
"field": "dissect_field",
1472+
"pattern" : "%{clientip} %{ident} %{auth} [%{@timestamp}] \"%{verb} %{request} HTTP/%{httpversion}\" %{status} %{size}"
1473+
}
1474+
}'
1475+
}
1476+
1477+
it 'establishes a connection' do
1478+
expect { subject.register }.not_to raise_error
1479+
end
1480+
end
14311481
end
14321482

14331483
end

spec/unit/elastic_integration_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,14 @@
412412
end
413413
end
414414

415+
describe "with `ssl_enabled`" do
416+
let(:config) { super().merge("ssl_enabled" => true) }
417+
418+
it "establishes a connection" do
419+
expect{ registered_plugin }.not_to raise_error
420+
end
421+
end
422+
415423
end
416424

417425
describe "with `ssl_verification_mode` is not `none`" do

src/main/java/co/elastic/logstash/filters/elasticintegration/ElasticsearchRestClientBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public void configureSSLContext(final SSLContextBuilder sslContextBuilder) {
340340
}
341341

342342
public void configureHttpClient(final HttpAsyncClientBuilder httpClientBuilder) {
343-
if (sslVerificationMode == SSLVerificationMode.CERTIFICATE) {
343+
if (sslVerificationMode == SSLVerificationMode.CERTIFICATE || sslVerificationMode == SSLVerificationMode.NONE ) {
344344
httpClientBuilder.setSSLHostnameVerifier(new NoopHostnameVerifier());
345345
}
346346
}

0 commit comments

Comments
 (0)