2014-05-08 2 views
3

Mon application android repose sur SNI pour accéder au bon serveur, donc il nécessite TLS et ne fonctionnera pas avec SSLv3. J'utilise okhttp et retrofit et les journaux du serveur indiquent que les handshakes TLS basculent soudainement en SSLv3 et peuvent rester ainsi pendant un temps de journal, entraînant des échecs répétés de vérification du nom d'hôte en raison du manque d'indication de nom de serveur.Comment désactiver SSLv3 fallback avec okhttp

Je comprends que dans certaines situations (lesquelles?), Okhttp arrête d'utiliser TLS et passe à SSL comme solution de repli. Cependant, ceci est inacceptable dans le cas de SNI, y a-t-il un moyen de désactiver le repli?

Exemple log apache:

[Wed May 07 18:00:12.799511 2014] [ssl:debug] [pid 20369:tid 140532403599104] ssl_engine_kernel.c(1891): [client <removed>:51431] AH02041: Protocol: TLSv1, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:00:28.563170 2014] [ssl:debug] [pid 20455:tid 140532646553344] ssl_engine_kernel.c(1891): [client <removed>:51432] AH02041: Protocol: TLSv1, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:00:45.884075 2014] [ssl:debug] [pid 20371:tid 140532445562624] ssl_engine_kernel.c(1891): [client <removed>:51433] AH02041: Protocol: TLSv1, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:01.322657 2014] [ssl:debug] [pid 20455:tid 140532395206400] ssl_engine_kernel.c(1891): [client <removed>:51434] AH02041: Protocol: TLSv1, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:18.361705 2014] [ssl:debug] [pid 20370:tid 140532462348032] ssl_engine_kernel.c(1891): [client <removed>:51435] AH02041: Protocol: TLSv1, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:25.378294 2014] [ssl:debug] [pid 20371:tid 140532487526144] ssl_engine_kernel.c(1891): [client <removed>:51436] AH02041: Protocol: SSLv3, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:40.807100 2014] [ssl:debug] [pid 20369:tid 140532445562624] ssl_engine_kernel.c(1891): [client <removed>:51437] AH02041: Protocol: SSLv3, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:41.154782 2014] [ssl:debug] [pid 20371:tid 140532479133440] ssl_engine_kernel.c(1891): [client <removed>:51438] AH02041: Protocol: SSLv3, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:56.695645 2014] [ssl:debug] [pid 20369:tid 140532504311552] ssl_engine_kernel.c(1891): [client <removed>:51439] AH02041: Protocol: SSLv3, Cipher: RC4-SHA (128/128 bits) 
[Wed May 07 18:01:57.252515 2014] [ssl:debug] [pid 20455:tid 140532521096960] ssl_engine_kernel.c(1891): [client <removed>:51440] AH02041: Protocol: SSLv3, Cipher: RC4-SHA (128/128 bits) 

Répondre

5

Grâce à la demande de fonctionnalité mentionnée ci-dessus, ceci a été ajouté en tant qu'option de configuration, voir here pour plus d'informations.

Si vous voulez avoir un client stricte/sécurisé qui ne tombe pas en arrière pour les suites de chiffrement non sécurisés utilisent ce ConnectionSpec:

client.setConnectionSpecs(Collections.singletonList(ConnectionSpec.MODERN_TLS)); 

Sinon, vous pouvez définir votre propre ConnectionSpec:

ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS) 
     .tlsVersions(TlsVersion.TLS_1_2) 
     .cipherSuites(
       CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, 
       CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 
       CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256) 
     .build(); 

    client.setConnectionSpecs(Collections.singletonList(spec));