2017-03-08 5 views
2

Java 7 Oracle ne prend pas en charge TLSv1.2. J'ai essayé d'exécuter mon code et j'ai essayé les choses suivantes:Java 7 Oracle ne prend pas en charge TLSv1.2

System.setProperty("deployment.security.TLSv1.1", "false") 
    System.setProperty("deployment.security.TLSv1", "false") 
    System.setProperty("deployment.security.TLSv1.2", "true") 
    System.setProperty("https.protocols", "TLSv1.2") 
    System.setProperty("https.cipherSuites", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,AES_256_GCM,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384") 

et il ne vous aide pas.

Comment puis-je forcer mon application Java7 à utiliser Tlsv1.2. Je peux lancer mon programme en utilisant java8 qui utilise par défaut TLS1.2 et tout fonctionne parfaitement.

Comment puis-je le faire en Java7 à partir d'oracle.

J'ai également essayé d'entrer dans /usr/lib/jvm/java-7-oracle/jre/lib/security et désactivé jdk.tls.disabledAlgorithms=SSLv2Hello, SSLv3, TLSv1 mais cela ne fonctionne toujours pas.

Qu'est-ce que je me trompe?

Btw Je reçois sslhandshakeexception-handshake-failure

EDIT:

Erreur:

0000: 02 28            .(
main, READ: TLSv1 Alert, length = 2 
main, RECV TLSv1 ALERT: fatal, handshake_failure 
main, called closeSocket() 
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 
166 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection - Connection [email protected] closed 
166 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection - Connection [email protected] shut down 
main, called close() 
main, called closeInternal(true) 


[main] DEBUG org.apache.http.impl.conn.BasicClientConnectionManager - Releasing connection [email protected] 
    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:1979) 
     at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086) 
     at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) 
     at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359) 
     at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343) 
     at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:533) 
     at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:401) 
     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177) 
     at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304) 
     at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611) 
     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446) 
     at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) 
     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72) 
     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:214) 
     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:160) 
+0

Votre demande est en cours d'exécution sous tomcat? –

+0

Non, ce n'est pas le cas. Je fais une demande GET à un service. Avec java8 je peux facilement le faire. Aussi avec mon navigateur Chrome, je peux voir la sortie de la demande – orange14

+0

Comment obtenez-vous le contexte SSL? 'SSLContext context = SSLContext.getInstance (" TLSv1.2 ");'? – dosdebug

Répondre

0

je vais répondre à ma propre question Incase quelqu'un a un problème similaire:

J'ai passé 2 jours à essayer tout et finalement je compris. En Java-7-oracle il n'est pas possible d'utiliser TLS1.2. Même la configuration à l'aide des propriétés du système ou même la configuration au niveau SSLContext ne m'a pas aidé. Leur soutien est très mauvais. Bien que dans Java-8-oracle, il est possible.

Simplement changer mon java à java-7-openjdk-amd64 a fait l'affaire pour moi.

1

je lance le même problème et, puisque je faisais mes demandes à l'aide de la bibliothèque client HTTP Apache, je l'ai résolu initialisation mon HttpClient cette façon

CloseableHttpClient client = HttpClients.custom() 
           .setSSLSocketFactory(getSSLContext()) 
           .build(); 

où le getSSLContext() méthode est cette

+0

J'utilise malheureusement org.apache.http.client.methods.HttpUriRequest. Importer d'une super classe que je ne veux pas modifier car beaucoup de classes en héritent. Quelqu'un d'autre a écrit ce code il y a 5 ans – orange14

0

Vous pouvez mettre à jour votre version Java 7 à 1.7.0_131-b31

Pour 1.7.0_131-b31 JRE dans le site Oracle:

TLSv1.2 and TLSv1.1 are now enabled by default on the TLS client end-points. This is similar behavior to what already happens in JDK 8 releases.