From 95695c8d88fbed6b775615b8e7aca34ded9cf719 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 9 Feb 2015 00:18:20 -0500 Subject: [PATCH] runner: Ignore dtlsFlushHandshake failures. This is consistent with ignoring writeRecord failures. Without doing this, the DTLS MinimumVersion test now flakily fails with: FAILED (MinimumVersion-Client-TLS12-TLS1-DTLS) bad error (wanted ':UNSUPPORTED_PROTOCOL:' / 'remote error: protocol version not supported'): local error 'write unix @: broken pipe', child error 'exit status 2', stdout: 2092242157:error:1007b1a7:SSL routines:ssl3_get_server_hello:UNSUPPORTED_PROTOCOL:../ssl/s3_clnt.c:783: This is because the MinimumVersion tests assert on /both/ expectedError and expectedLocalError. The latter is valuable as it asserts on the alert the peer returned. (I would like us to add more such assertions to our tests where appropriate.) However, after we send ServerHello, we also send a few messages following it. This races with the peer shutdown and we sometimes get EPIPE before reading the alert. Change-Id: I3fe37940a6a531379673a00976035f8e76e0f825 Reviewed-on: https://boringssl-review.googlesource.com/3337 Reviewed-by: Adam Langley --- ssl/test/runner/handshake_client.go | 20 +++++--------------- ssl/test/runner/handshake_server.go | 16 ++++------------ 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/ssl/test/runner/handshake_client.go b/ssl/test/runner/handshake_client.go index c798109c..49fb6721 100644 --- a/ssl/test/runner/handshake_client.go +++ b/ssl/test/runner/handshake_client.go @@ -214,9 +214,7 @@ NextCipherSuite: helloBytes = hello.marshal() c.writeRecord(recordTypeHandshake, helloBytes) } - if err := c.dtlsFlushHandshake(true); err != nil { - return err - } + c.dtlsFlushHandshake(true) if err := c.simulatePacketLoss(nil); err != nil { return err @@ -240,9 +238,7 @@ NextCipherSuite: hello.cookie = helloVerifyRequest.cookie helloBytes = hello.marshal() c.writeRecord(recordTypeHandshake, helloBytes) - if err := c.dtlsFlushHandshake(true); err != nil { - return err - } + c.dtlsFlushHandshake(true) if err := c.simulatePacketLoss(nil); err != nil { return err @@ -621,9 +617,7 @@ func (hs *clientHandshakeState) doFullHandshake() error { hs.writeClientHash(certVerify.marshal()) c.writeRecord(recordTypeHandshake, certVerify.marshal()) } - if err := c.dtlsFlushHandshake(true); err != nil { - return err - } + c.dtlsFlushHandshake(true) hs.finishedHash.discardHandshakeBuffer() @@ -859,9 +853,7 @@ func (hs *clientHandshakeState) sendFinished(isResume bool) error { c.writeRecord(recordTypeHandshake, postCCSBytes[:5]) postCCSBytes = postCCSBytes[5:] } - if err := c.dtlsFlushHandshake(true); err != nil { - return err - } + c.dtlsFlushHandshake(true) if !c.config.Bugs.SkipChangeCipherSpec && c.config.Bugs.EarlyChangeCipherSpec == 0 { @@ -874,9 +866,7 @@ func (hs *clientHandshakeState) sendFinished(isResume bool) error { if !c.config.Bugs.SkipFinished { c.writeRecord(recordTypeHandshake, postCCSBytes) - if err := c.dtlsFlushHandshake(false); err != nil { - return err - } + c.dtlsFlushHandshake(false) } return nil } diff --git a/ssl/test/runner/handshake_server.go b/ssl/test/runner/handshake_server.go index de5d7b7f..9c920d6e 100644 --- a/ssl/test/runner/handshake_server.go +++ b/ssl/test/runner/handshake_server.go @@ -149,9 +149,7 @@ func (hs *serverHandshakeState) readClientHello() (isResume bool, err error) { return false, errors.New("dtls: short read from Rand: " + err.Error()) } c.writeRecord(recordTypeHandshake, helloVerifyRequest.marshal()) - if err := c.dtlsFlushHandshake(true); err != nil { - return false, err - } + c.dtlsFlushHandshake(true) if err := c.simulatePacketLoss(nil); err != nil { return false, err @@ -549,9 +547,7 @@ func (hs *serverHandshakeState) doFullHandshake() error { helloDone := new(serverHelloDoneMsg) hs.writeServerHash(helloDone.marshal()) c.writeRecord(recordTypeHandshake, helloDone.marshal()) - if err := c.dtlsFlushHandshake(true); err != nil { - return err - } + c.dtlsFlushHandshake(true) var pub crypto.PublicKey // public key for client auth, if any @@ -845,9 +841,7 @@ func (hs *serverHandshakeState) sendFinished() error { c.writeRecord(recordTypeHandshake, postCCSBytes[:5]) postCCSBytes = postCCSBytes[5:] } - if err := c.dtlsFlushHandshake(true); err != nil { - return err - } + c.dtlsFlushHandshake(true) if !c.config.Bugs.SkipChangeCipherSpec { c.writeRecord(recordTypeChangeCipherSpec, []byte{1}) @@ -859,9 +853,7 @@ func (hs *serverHandshakeState) sendFinished() error { if !c.config.Bugs.SkipFinished { c.writeRecord(recordTypeHandshake, postCCSBytes) - if err := c.dtlsFlushHandshake(false); err != nil { - return err - } + c.dtlsFlushHandshake(false) } c.cipherSuite = hs.suite.id