Merge pull request #1992 from lucas-clemente/explicitly-send-session-tickets

explicitly send session tickets
This commit is contained in:
Marten Seemann
2019-07-05 21:30:26 +07:00
committed by GitHub
3 changed files with 25 additions and 7 deletions

2
go.mod
View File

@@ -7,7 +7,7 @@ require (
github.com/golang/mock v1.2.0
github.com/golang/protobuf v1.3.0
github.com/marten-seemann/qpack v0.1.0
github.com/marten-seemann/qtls v0.3.0
github.com/marten-seemann/qtls v0.3.1
github.com/onsi/ginkgo v1.7.0
github.com/onsi/gomega v1.4.3
golang.org/x/crypto v0.0.0-20190228161510-8dd112bcdc25

4
go.sum
View File

@@ -12,8 +12,8 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/marten-seemann/qpack v0.1.0 h1:/0M7lkda/6mus9B8u34Asqm8ZhHAAt9Ho0vniNuVSVg=
github.com/marten-seemann/qpack v0.1.0/go.mod h1:LFt1NU/Ptjip0C2CPkhimBz5CGE3WGDAUWqna+CNTrI=
github.com/marten-seemann/qtls v0.3.0 h1:jewioNbXlqAprZpfDu8VXq/dYwu2EFgCLQjbVGNqHBw=
github.com/marten-seemann/qtls v0.3.0/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
github.com/marten-seemann/qtls v0.3.1 h1:ySYIvhFjFY2JsNHY6VACvomMEDy3EvdPA6yciUFAiHw=
github.com/marten-seemann/qtls v0.3.1/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=

View File

@@ -16,8 +16,12 @@ import (
"github.com/marten-seemann/qtls"
)
// TLS unexpected_message alert
const alertUnexpectedMessage uint8 = 10
const (
// TLS unexpected_message alert
alertUnexpectedMessage uint8 = 10
// TLS internal error
alertInternalError uint8 = 80
)
type messageType uint8
@@ -264,6 +268,10 @@ func (h *cryptoSetup) RunHandshake() {
select {
case <-handshakeComplete: // return when the handshake is done
h.runner.OnHandshakeComplete()
// send a session ticket
if h.perspective == protocol.PerspectiveServer {
h.maybeSendSessionTicket()
}
case <-h.closeChan:
close(h.messageChan)
// wait until the Handshake() go routine has returned
@@ -443,6 +451,18 @@ func (h *cryptoSetup) handleMessageForClient(msgType messageType) bool {
}
}
// only valid for the server
func (h *cryptoSetup) maybeSendSessionTicket() {
ticket, err := h.conn.GetSessionTicket()
if err != nil {
h.onError(alertInternalError, err.Error())
return
}
if ticket != nil {
h.oneRTTStream.Write(ticket)
}
}
func (h *cryptoSetup) handlePostHandshakeMessage(data []byte) {
// make sure the handshake has already completed
<-h.handshakeDone
@@ -543,8 +563,6 @@ func (h *cryptoSetup) WriteRecord(p []byte) (int, error) {
return n, err
case protocol.EncryptionHandshake:
return h.handshakeStream.Write(p)
case protocol.Encryption1RTT:
return h.oneRTTStream.Write(p)
default:
panic(fmt.Sprintf("unexpected write encryption level: %s", h.writeEncLevel))
}