3
votes

I’m writing a program in java that send official invoice information to the Fiscal Administration. This public service provided certificates to use in the SSL connection to the web services and to encrypt some especial data fields inside the request body message.

I’m having an EOFException error during the handshake phase after client and server have agreed to communicate using the agreed cipher suite that in this case is TLS_RSA_WITH_AES_128_CBC_SHA.

Following the SSL protocol the client perform with success a test using the new cipher and send the test data to the server so the server can also repeat the same test and confirm that it is also capable of encrypt and decrypt data. And in this point the server send the EOFException.

Here is the last part of the SSL communication log:

Send a quick confirmation to the server verifying that we know the private key corresponding to the client certificate we just sent...

* CertificateVerify

[write] MD5 and SHA1 hashes: len = 262

binary data here too large not displayed

main, WRITE: TLSv1 Handshake, length = 262

[Raw write]: length = 267

binary data here too large not displayed

*Tell the server we're changing to the newly established cipher suite. All further messages will be encrypted using the parameters we just established. *

main, WRITE: TLSv1 Change Cipher Spec, length = 1

[Raw write]: length = 6

0000: 14 03 01 00 01 01

... and finishes with success

..Finished

We send an encrypted Finished message to verify everything worked.

verify_data: { 221, 96, 47, 110, 19, 170, 244, 8, 37, 152, 160, 40 }

... The client encrypt the test data..

[write] MD5 and SHA1 hashes: len = 16

0000: 14 00 00 0C DD 60 2F 6E 13 AA F4 08 25 98 A0 28 .....`/n....%..(

Padded plaintext before ENCRYPTION: len = 48

0000: 14 00 00 0C DD 60 2F 6E 13 AA F4 08 25 98 A0 28 .....`/n....%..(

0010: 10 7F 85 11 EC 6D 5D ED 21 70 27 F4 DC 23 C0 9B .....m].!p'..#..

0020: A7 6F C2 80 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B 0B .o..............

main, WRITE: TLSv1 Handshake, length = 48

* ...and send the test data to the server so that the server can do the same test and confirm that encrypted communication can be established (53 bytes = 48 from the test data + 5 from header) *

[Raw write]: length = 53

0000: 16 03 01 00 30 1C 17 08 0F 49 C9 6A 7A 8B 8C 48 ....0....I.jz..H

0010: BA 57 2D CB 06 46 1E 65 61 7C 5F 74 F2 08 AB 12 .W-..F.ea._t....

0020: 91 47 72 8C 8F 84 0A CB D7 29 E2 FD 84 B2 FD 9E .Gr......)......

0030: 47 DC 13 60 B4 G..`.

...and the server respond with the EOFException error

main, received EOFException: error

main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed

connection during handshake

%% Invalidated: [Session-1, TLS_RSA_WITH_AES_128_CBC_SHA]

main, SEND TLSv1 ALERT: fatal, description = handshake_failure

Padded plaintext before ENCRYPTION: len = 32

0000: 02 28 BC 65 1A CA 68 87 79 84 5F 64 16 F5 28 72 .(.e..h.y._d..(r

0010: F7 8A 69 72 93 D8 09 09 09 09 09 09 09 09 09 09 ..ir............

main, WRITE: TLSv1 Alert, length = 32

[Raw write]: length = 37

0000: 15 03 01 00 20 0D 9A 35 18 B7 98 4B 7B AF 82 4E .... ..5...K...N

0010: 1A EE 7D AC 5D D5 49 05 4E 74 B9 77 E4 CD 87 61 ....].I.Nt.w...a

0020: 23 03 5C 9C 7E #...

main, called closeSocket()

main, called close()

main, called closeInternal(true)

I have no idea on what might be the cause for such a failure and how to programmatically influence the outcome of this step in the process. I’ve tried force the use of other ciphers recognized by both client and server such as SSL_RSA_WITH_RC4_128_MD5 but the error remain. Any thoughts on how to solve this problem?

1
The server didn't 'respond with an EOFException error'. The server closed the connection, which caused the client to get the EOFException.user207421

1 Answers

2
votes

Any thoughts on how to solve this problem?

I suggest that you get in contact with the people who run that service, and get them to look at their logs to see why their server is closing the connection during SSL setup.

(Strictly speaking, the server does not "respond with [an] EOFException error". It is actually closing the TCP connection and the client-side Java libraries are throwing the exception. You are likely to get a more helpful response from the maintainers of the service if you use correct terminology.)