Ошибка ввода-вывода при отправке запроса на URL : Получено предупреждение о неустранимой ошибке: рукопожатие.

#spring-boot #ssl #resttemplate #sslhandshakeexception

Вопрос:

Я пытаюсь подключить безопасный REST API через Spring RestTemplate в приложении для загрузки спринта. Я получаю следующую ошибку :

 I/O error on POST request for "URL": Received fatal alert: handshake_failure; nested exception is javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
 

Конфигурация RestTemplate компонента:

 public RestTemplate restTemplate() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException, UnrecoverableKeyException, CertificateException, FileNotFoundException, IOException {
        
        char[] all = "mypassword".toCharArray();
        KeyStore ks = KeyStore.getInstance("JKS");
        try (InputStream stream = this.getClass().getClassLoader().getResourceAsStream("mycert.jks")) {
            ks.load(stream, all);
            IOUtils.closeQuietly(stream);
        }

        SSLContext sslContext = new SSLContextBuilder()
                .loadKeyMaterial(ks, all).loadTrustMaterial(new TrustSelfSignedStrategy()).build();

        SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
        
        HttpClientBuilder clientBuilder = HttpClientBuilder.create();
        clientBuilder.setSSLSocketFactory(csf);
        
        CloseableHttpClient httpClient = clientBuilder.build();

        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
        requestFactory.setHttpClient(httpClient);
        requestFactory.setBufferRequestBody(false);

        return new RestTemplate(requestFactory);
        
}
 

Журнал консоли приложения (Pod) :

 --------> o.s.web.client.RestTemplate              : HTTP POST https://URL--------> o.s.web.client.RestTemplate              : Accept=[text/plain, application/json, application/* json, */*]--------> o.s.web.client.RestTemplate              : Writing [com.ril.model.json.request] as "application/json"--------> o.a.h.client.protocol.RequestAddCookies  : CookieSpec selected: default--------> o.a.h.client.protocol.RequestAuthCache   : Auth cache not set in the context--------> h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {s}->https://url:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]--------> h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {s}->https://URL:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]--------> o.a.http.impl.execchain.MainClientExec   : Opening connection {s}->https://url:443--------> .i.c.DefaultHttpClientConnectionOperator : Connecting to url/10.21.252.51:443--------> o.a.h.c.ssl.SSLConnectionSocketFactory   : Connecting socket to url/10.21.252.51:443 with timeout 0--------> o.a.h.c.ssl.SSLConnectionSocketFactory   : Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]--------> o.a.h.c.ssl.SSLConnectionSocketFactory   : Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]--------> o.a.h.c.ssl.SSLConnectionSocketFactory   : Starting handshake--------> h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: Shutdown connection--------> o.a.http.impl.execchain.MainClientExec   : Connection discarded--------> h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: Close connection--------> h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: 0][route: {s}->https://URL:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]--------> BLActualizationUpdateResponseServiceImpl : Failed to get remote resource because: I/O error on POST request for "url": Received fatal alert: handshake_failure; nested exception is javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure-------->com.ril.aop.LogAop                       : Exception in ===: -------->com.ril.aop.LogAop                       : org.springframework.web.client.ResourceAccessException: I/O error on POST request for "url": Received fatal alert: handshake_failure; nested exception is javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
 

Я напрасно перепробовал множество способов устранения ошибки.

Это из вывода вкладки безопасность инструмента разработчика chrome для целевого API