Received fatal alert: handshake_failure when the class is executed by Schedule - JDK7

2

I have a class that does integration with WooCommerce, when I run the class when I upload the project not to httpClient error (4.5.3) I get the HttpResponse 200 ok, I have two api registered,

1 ° link e  2 ° link

Both have the same TLS and cipherSuites that is acceptable, but when the schedule executes the second handshake_failure error integration api, I have already tried all of the ways I looked in the stackOverFlow and Oracle website.

My socket code.

         builder = new SSLContextBuilder();
         builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());

         SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(builder.build(),new String[] {"TLSv1","TLSv1.1","TLSv1.2"},
                 null,NoopHostnameVerifier.INSTANCE); // EVITAR 
            // com cipherSuites da o mesmo erro

         Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
                    .register("http", new PlainConnectionSocketFactory())
                    .register("https", sslConnectionSocketFactory)
                    .build();

         PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
         cm.setMaxTotal(100);
         this.httpClient = HttpClients.custom()
                    .setSSLSocketFactory(sslConnectionSocketFactory)
                    .setConnectionManager(cm)
                    .build();

        this.mapper = new ObjectMapper();

The error happens when I get to this part

try {
            HttpHost https = new HttpHost(httpHost.replace("https://", ""), 443, "https");//host e numero da porta https

            HttpResponse httpResponse = httpClient.execute(https, httpRequest); // AQUI

Whenever it is executed by schedule at the specified time

<bean id="cronSincronizarPedidoApi" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="sincronizarPedido" />
    <property name="cronExpression" value="0 56 6-20/2 * * ?" /><!-- Programado para cada 2h entre 6h e 20h-->
</bean>

Note: I've tried replacing JCE but also did not work,

With JDK8 it solves the error but it is a large ERP system I can not change the version of java using JDK7.

I also do not know if when executing the schedule it compiles only class data, not uploading necessary files when you upload the "Run" project.

LOGS

java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at br.com.erp.web.rest.woocommerce.DefaultHttpClient.getEntityAndReleaseConnection(DefaultHttpClient.java:183)
at br.com.erp.web.rest.woocommerce.DefaultHttpClient.getAll(DefaultHttpClient.java:100)
at br.com.erp.web.rest.woocommerce.WooCommerceAPI.allProduct(WooCommerceAPI.java:63)
at br.com.erp.web.rest.woocommerce.WooCommerceAPI.getAll(WooCommerceAPI.java:50)
at br.com.controlese.schedule.ScheduleSincronizarPedidoVenda.sincronizarPedido(ScheduleSincronizarPedidoVenda.java:120)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:269)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:272)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)


Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1977)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1093)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1328)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:118)
at br.com.erp.web.rest.woocommerce.DefaultHttpClient.getEntityAndReleaseConnection(DefaultHttpClient.java:172)
... 13 more
    
asked by anonymous 11.06.2018 / 19:29

0 answers