spring-cloud-gateway
spring-cloud-gateway copied to clipboard
[SpringCloudGateway]: Netty HttpClient failed to connect with SSLHandshakeException after establishing HTTPS connection with endpoint
We have built API Gateway application using Spring Cloud Gateway 4.0 (on webflux) framework and Azul Zulu OpendJDK 17. The application is able to intercept incoming request and redirect it to the configured downstream HTTPS endpoint using TLS certificate. However, there is one request in which the gateway app unable to establish HTTPS connection with configured downstream endpoint and getting below SSL Handshake error (soon after connection and active channel):
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
We have configured the TLS certificate for routing request to endpoint in following property which is passed as JVM_ARGS in java command line:
javax.net.ssl.trustStore=<path to .pkcs12 keystore>
We enabled more granular logs from Netty library by setting reactor.netty=DEBUG level and found below lines after above exception:
HttpServerOperations | [d7cffb05-1, L:/<Source IP:Port> - R:/<Destination IP:Port>] Detected non persistent http connection, preparing to close
HttpServerOperations | [d7cffb05-1, L:/<Source IP:Port> - R:/<Destination IP:Port>] Last HTTP response frame
HttpServerOperations | [d7cffb05-1, L:/<Source IP:Port> - R:/<Destination IP:Port>] Last HTTP packet was sent, terminating the channel
However, Netflix Zuul Gateway application (running on same server in which Spring Cloud Gateway app is running) is able to connect with the same HTTPS endpoint and redirect the request to it successfully using same TLS certificate. Note:** Netflix Zuul is using RestTemplate to connect whereas Spring Cloud Gateway is using Netty HttpClient.**
We have tried many combination with different properties however still stuck with same error. How can we resolve this SSL handshake failure soon after connection is established? Any help is highly appreciated in this direction.