Skip to content

Commit f0f454c

Browse files
committed
Apply suggestions from code review
1 parent 967734c commit f0f454c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/java/org/logstash/plugins/inputs/http/util/SslSimpleBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public SslSimpleBuilder setTrustStore(String trustStoreType, String trustStoreFi
189189
);
190190

191191
if (!hasTrustStoreEntry(this.trustStore)) {
192-
logger.warn("The provided Trust Store file does not contains any trusted certificate entry: {}. Please confirm this is the correct certificate and the password is correct", trustStoreFile);
192+
throw new IllegalArgumentException(String.format("The provided Trust Store file does not contains any trusted certificate entry: %s", trustStoreFile));
193193
}
194194

195195
return this;

src/test/java/org/logstash/plugins/inputs/http/util/SslSimpleBuilderTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ void testSetTrustStoreWithNullTrustStoreType() throws Exception {
211211
assertEquals(TRUSTSTORE_TYPE, sslSimpleBuilder.getTrustStore().getType());
212212
}
213213

214+
@Test
215+
void testSetTrustStoreWithNoTrustedCertificate() {
216+
assertThrows(
217+
IllegalArgumentException.class,
218+
() -> createPemSslSimpleBuilder().setTrustStore(KEYSTORE_TYPE, KEYSTORE, KEYSTORE_PASSWORD),
219+
String.format("The provided Trust Store file does not contains any trusted certificate entry: %s", KEYSTORE)
220+
);
221+
}
222+
214223
@Test
215224
void testDefaultVerifyModeIsNone() {
216225
final SslSimpleBuilder sslSimpleBuilder = createPemSslSimpleBuilder();

0 commit comments

Comments
 (0)