title: Connection reset by peer on Java 8, but not on Java 7
body: <p>I'm having a problem that's very similar to <a href="https://stackoverflow.com/questions/28978070/connection-reset-by-peer-calling-soap-webservice">mel3kings' question</a>, but, in my case, the connection works OK with Java 7 update 79, but not with Java 8 update 51; any ideas on what could be causing this?</p>
  
  <p>I'm trying to connect to a secure webservice, using a SunMSCAPI keystore. The truststore is up-to-date. The connection works perfectly on Java 7, but on Java 8, it gives this error:</p>
  
  <pre><code>***
  *** ClientKeyExchange, RSA PreMasterSecret, TLSv1
  Execução de comandos de NFe, WRITE: TLSv1 Handshake, length = 7648
  SESSION KEYGEN:
  PreMaster Secret:
  0000: 03 01 2D 6C 21 6D D6 EE   68 9F 27 10 60 99 EB 82  ..-l!m..h.'.`...
  0010: 85 4D 41 B8 0C 38 B7 2D   98 72 FB 51 07 BC 9A D7  .MA..8.-.r.Q....
  0020: 60 76 98 D6 C8 8E 0B 1C   86 DB A0 98 68 CC 35 73  `v..........h.5s
  CONNECTION KEYGEN:
  Client Nonce:
  0000: 55 AF DF 74 AE 34 06 95   82 44 92 2B BD 0A 65 2C  U..t.4...D.+..e,
  0010: ED 77 4E E8 49 32 06 8A   BE F6 69 49 34 D9 68 A9  .wN.I2....iI4.h.
  Server Nonce:
  0000: 55 AF DF 74 A3 84 C6 57   43 14 F2 13 F4 7E BF 77  U..t...WC......w
  0010: C6 CD A6 B5 8E 01 4E 01   F9 42 B0 60 4D 82 27 81  ......N..B.`M.'.
  Master Secret:
  0000: BE 6E A8 76 F3 58 4E 53   B5 70 7D 43 6A 2D 1D 6F  .n.v.XNS.p.Cj-.o
  0010: 3C C4 DE 7D 2A 3C 40 A3   D8 65 CA 38 43 8E 75 4D  &lt;...*&lt;@..e.8C.uM
  0020: A4 05 2D 60 6C 82 5B E1   73 EE E1 CC B3 1A 64 CE  ..-`l.[.s.....d.
  Client MAC write Secret:
  0000: B7 21 C6 E4 CB 05 2C B5   B7 83 9A 8A D4 5F 39 00  .!....,......_9.
  0010: E5 6A AA 9D                                        .j..
  Server MAC write Secret:
  0000: 0B 27 C3 1F D9 84 57 8D   43 F0 17 5C 25 05 70 BB  .'....W.C..\%.p.
  0010: 40 70 6D 4E                                        @pmN
  Client write key:
  0000: EC B4 F8 09 3F 8C 8F FD   C3 8F 31 6E 4C AF DC 93  ....?.....1nL...
  Server write key:
  0000: 07 7D 2A A1 E5 75 33 87   B8 19 D9 43 CB 6A CE 09  ..*..u3....C.j..
  Client write IV:
  0000: 5D 16 DC E7 DD 0C 00 8F   18 01 05 C0 5B E6 9C 5D  ]...........[..]
  Server write IV:
  0000: 0D E4 19 20 44 69 05 33   1C 05 78 4E CB 4A 8C CA  ... Di.3..xN.J..
  *** CertificateVerify
  Execução de comandos de NFe, WRITE: TLSv1 Handshake, length = 288
  Execução de comandos de NFe, WRITE: TLSv1 Change Cipher Spec, length = 32
  *** Finished
  verify_data:  { 90, 183, 147, 207, 60, 73, 195, 204, 200, 29, 186, 245 }
  ***
  Execução de comandos de NFe, WRITE: TLSv1 Handshake, length = 48
  Execução de comandos de NFe, handling exception: java.net.SocketException: Connection reset
  %% Invalidated:  [Session-3, TLS_RSA_WITH_AES_128_CBC_SHA]
  %% Invalidated:  [Session-4, TLS_RSA_WITH_AES_128_CBC_SHA]
  SEND TLSv1 ALERT:  fatal, description = unexpected_message
  WRITE: TLSv1 Alert, length = 32
  Exception sending alert: java.net.SocketException: Connection reset by peer: socket write error
  called closeSocket()
  called close()
  called closeInternal(true)
  called close()
  called closeInternal(true)
  </code></pre>