I’m getting 2 errors SSLHandshakeException when making requests through WebClient. Even though I am catching the exceptions succesfully (custom LOG4J log warn is being displayed) the stack trace is printed on the console.
It is a reactive app with Spring WebFlux in Java, so the server is netty. These are the exceptions:
javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification.
I’m adding the method with the error handled with onErrorResume. I’m getting the error message and the app keeps running, but the stack trace is being printed on the console anyway. This happens for SSLExceptions and variants of it. I’ve tried changing config for LOG4J, creating XML file, a Global Exception Handler and nothing works.
public Mono<Token> getToken(String tokenUri, String sellerId) {
return this.webClient.post()
.uri(tokenUri)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.accept(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromFormData("grant_type", "password")
.with("username", "XXX")
.with("password", "XXXXXX"))
.retrieve()
.bodyToMono(Token.class)
.onErrorResume(e -> {
log.error("Error getting token for Seller {}. URL {}: {}", sellerId, tokenUri, e.getMessage());
return Mono.empty();
});
}
A bit more of the stack trace:
STACK TRACE
Pomelooo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.