Skip to content

Commit

Permalink
Improve error message when a node with an incorrectly configured cert…
Browse files Browse the repository at this point in the history
…ificate attempts to connect

Updated the error message to understand what is the exact reason and renamed the API name to match the intention of API.

Resolves opensearch-project#4601

Signed-off-by: Abdul Muneer Kolarkunnu <muneer.kolarkunnu@netapp.com>
  • Loading branch information
akolarkunnu committed Oct 18, 2024
1 parent 85134f7 commit 9ecd5f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public static OpenSearchException createJwkCreationException(Throwable cause) {
}

public static OpenSearchException clusterWrongNodeCertConfigException(String sslPrincipal) {
return new OpenSearchException("Node presenting certificate with SSL Principal {" + sslPrincipal + "} could" +
" not securely connect to the cluster. Please ensure the principal is correct and present in the" +
" nodes_dn list.");
return new OpenSearchException(
"Node presenting certificate with SSL Principal {"
+ sslPrincipal
+ "} could"
+ " not securely connect to the cluster. Please ensure the principal is correct and present in the"
+ " nodes_dn list."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1355,9 +1355,14 @@ public void testCcsWithDiffCertsWithNoNodesDnUpdate() throws Exception {
String uri = "cross_cluster_two:twitter/_search?pretty";
HttpResponse ccs = rh1.executeGetRequest(uri, encodeBasicHeader("twitter", "nagilum"));
assertThat(ccs.getStatusCode(), equalTo(HttpStatus.SC_INTERNAL_SERVER_ERROR));
assertThat(ccs.getBody(), containsString("Node presenting certificate with SSL Principal " +
"{CN=node-0.example.com,OU=SSL,O=Test,L=Test,C=DE} could not securely connect to the cluster. Please" +
" ensure the principal is correct and present in the nodes_dn list."));
assertThat(
ccs.getBody(),
containsString(
"Node presenting certificate with SSL Principal "
+ "{CN=node-0.example.com,OU=SSL,O=Test,L=Test,C=DE} could not securely connect to the cluster. Please"
+ " ensure the principal is correct and present in the nodes_dn list."
)
);
}

@Test
Expand Down

0 comments on commit 9ecd5f4

Please sign in to comment.