-1

I am trying to build a java code and run the jar file. I am using Java 1.8.0_201 for running the jar, but while running it fails to generate token from server due to handshake failure. This happens mainly due to protocol mismatch. ( Client sends request in TLSv1 and the server returns in TLSv1.2 , leading to protocol mismatch )

The Question is why is java 1.8 using TLSv1 when the default is TLSv1.2. I have checked /jre/lib/security/java.security file , the configuration seems fine there.

Ignoring unsupported cipher suite: SSL_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
Ignoring unsupported cipher suite: SSL_ECDH_RSA_WITH_AES_128_GCM_SHA256
Ignoring unsupported cipher suite: SSL_DHE_RSA_WITH_AES_128_GCM_SHA256
Ignoring unsupported cipher suite: SSL_DHE_DSS_WITH_AES_128_GCM_SHA256
%% No cached client session
ALPNJSSEExt not initialzed for Client
*** ClientHello, TLSv1
RandomCookie:  GMT: 1538275877 bytes = { 241, 176, 51, 175, 86, 198, 212, 80, 127, 148, 227, 71, 225, 187, 76, 30, 151, 32, 213, 28, 179, 237, 196, 200, 111, 252, 126, 198 }
Session ID:  {}
Cipher Suites: [SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_AES_256_CBC_SHA, SSL_ECDH_ECDSA_WITH_AES_256_CBC_SHA, SSL_ECDH_RSA_WITH_AES_256_CBC_SHA, SSL_DHE_RSA_WITH_AES_256_CBC_SHA, SSL_DHE_DSS_WITH_AES_256_CBC_SHA, SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_AES_128_CBC_SHA, SSL_ECDH_ECDSA_WITH_AES_128_CBC_SHA, SSL_ECDH_RSA_WITH_AES_128_CBC_SHA, SSL_DHE_RSA_WITH_AES_128_CBC_SHA, SSL_DHE_DSS_WITH_AES_128_CBC_SHA]
Compression Methods:  { 0 }
Extension renegotiation_info, ri_length: 0, ri_connection_data: { null }
Extension elliptic_curves, curve names: {secp256r1, secp384r1, secp521r1, secp256k1}
Extension ec_point_formats, formats: [uncompressed]
Extension extended_master_secret
Extension server_name, server_name: [type=host_name (0), value=<>]
***
[write] MD5 and SHA1 hashes:  len = 140
0000: 01 00 00 88 03 01 5c b0  3a 25 f1 b0 33 af 56 c6  ............3.V.
0010: d4 50 7f 94 e3 47 e1 bb  4c 1e 97 20 d5 1c b3 ed  .P...G..L.......
0020: c4 c8 6f fc 7e c6 00 00  1c c0 0a c0 14 00 35 c0  ..o...........5.
0030: 05 c0 0f 00 39 00 38 c0  09 c0 13 00 2f c0 04 c0  ....9.8.........
0040: 0e 00 33 00 32 01 00 00  43 ff 01 00 01 00 00 0a  ..3.2...C.......
0050: 00 0a 00 08 00 17 00 18  00 19 00 16 00 0b 00 02  ................
0060: 01 00 00 17 00 00 00 00  00 22 00 20 00 00 1d 73  ...............
0070: 64 70 2d 63 77 73 2e 73  64 70 31 32 2d 69 73 74  
0080: 67 2e 63 73 63 6f 2e 63  6c 6f 75 64              

main, WRITE: TLSv1 Handshake, length = 140
[Raw write]: length = 145
0000: 16 03 01 00 8c 01 00 00  88 03 01 5c b0 3a 25 f1  ................
0010: b0 33 af 56 c6 d4 50 7f  94 e3 47 e1 bb 4c 1e 97  .3.V..P...G..L..
0020: 20 d5 1c b3 ed c4 c8 6f  fc 7e c6 00 00 1c c0 0a  .......o........
0030: c0 14 00 35 c0 05 c0 0f  00 39 00 38 c0 09 c0 13  ...5.....9.8....
0040: 00 2f c0 04 c0 0e 00 33  00 32 01 00 00 43 ff 01  .......3.2...C..
0050: 00 01 00 00 0a 00 0a 00  08 00 17 00 18 00 19 00  ................
0060: 16 00 0b 00 02 01 00 00  17 00 00 00 00 00 22 00  ................
0070: 20 00 00 1d 73 64 70 2d  63 77 73 2e 73 64 70 31  ....
0080: 32 2d 69 73 74 67 2e 63  73 63 6f 2e 63 6c 6f 75  
0090: 64                                                 

[Raw read]: length = 5
0000: 15 03 01 00 02                                     .....

[Raw read]: length = 2
0000: 02 46                                              .F

main, READ: TLSv1 Alert, length = 2
main, RECV TLSv1.2 ALERT:  fatal, protocol_version
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLException: Received fatal alert: protocol_version

The clientHello should list TLSv1.2, but why its showing TLSv1 ? As the client supports TLSv1.2 and moreover I am using java1.8

1 Answers1

0

I have faced the same problem for the API which used to use an SSL connection to exchange data with the third party provider. Simply, I disabled the lower level security algorithms. This setting forces the server to accept only TLSv1.2 connection.

jdk.tls.disabledAlgorithms= SSLv2Hello, SSLv3, TLSv1, TLSv1.1

Adding this parameter inside jre/lib/security/java.security file should solve your problem.

Ekin Yücel
  • 112
  • 5
  • 7