Skip to content

Commit

Permalink
[Backport 2.x] Improve error message when a node with an incorrectly …
Browse files Browse the repository at this point in the history
…configured certificate attempts to connect (#4819)

Signed-off-by: Abdul Muneer Kolarkunnu <muneer.kolarkunnu@netapp.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent fec977a commit 5902191
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ public static OpenSearchException createJwkCreationException(Throwable cause) {
return new OpenSearchException("An error occurred during the creation of Jwk: {}", cause, cause.getMessage());
}

public static OpenSearchException createTransportClientNoLongerSupportedException() {
return new OpenSearchException("Transport client authentication no longer supported.");
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."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ protected void messageReceivedDecorate(
|| HeaderHelper.isTrustedClusterRequest(getThreadContext())
|| HeaderHelper.isExtensionRequest(getThreadContext()))) {
// CS-ENFORCE-SINGLE
final OpenSearchException exception = ExceptionUtils.createTransportClientNoLongerSupportedException();
final OpenSearchException exception = ExceptionUtils.clusterWrongNodeCertConfigException(principal);
log.error(exception.toString());
transportChannel.sendResponse(exception);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +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("Transport client authentication no longer supported"));
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 5902191

Please sign in to comment.