Skip to content

Commit

Permalink
FIX: null certificate value should be valid in opensearch connection (o…
Browse files Browse the repository at this point in the history
…pensearch-project#4494)

* FIX: null certificate value should be valid

Signed-off-by: George Chen <qchea@amazon.com>
  • Loading branch information
chenqi0805 authored May 2, 2024
1 parent d6a8ae0 commit acc936c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Objects;

public class ConnectionConfiguration {

Expand Down Expand Up @@ -62,7 +63,7 @@ boolean certificateFileAndContentAreMutuallyExclusive() {

@AssertTrue(message = "certificate must be either valid PEM file path or public key content.")
boolean isCertificateValid() {
if (PemObjectValidator.isPemObject(certificate)) {
if (Objects.isNull(certificate) || PemObjectValidator.isPemObject(certificate)) {
return true;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void connection_configuration_values_test() throws JsonProcessingException {
assertThat(connectionConfig.getSocketTimeout(),equalTo(null));
assertThat(connectionConfig.getConnectTimeout(),equalTo(null));
assertThat(connectionConfig.isInsecure(),equalTo(true));
assertThat(connectionConfig.isCertificateValid(), is(true));
}

@ParameterizedTest
Expand Down

0 comments on commit acc936c

Please sign in to comment.