Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when a node with an incorrectly configured certificate attempts to connect #4818

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -290,7 +290,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
Loading