Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/crypto/tls/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -924,13 +924,9 @@ var supportedVersions = []uint16{
func (c *Config) supportedVersions() []uint16 {
versions := make([]uint16, 0, len(supportedVersions))
for _, v := range supportedVersions {
if c != nil && c.MinVersion != 0 && v < c.MinVersion {
continue
}
if c != nil && c.MaxVersion != 0 && v > c.MaxVersion {
continue
if c != nil && v >= c.MinVersion && (c.MaxVersion==0 || v <= c.MaxVersion) {
versions = append(versions, v)
}
versions = append(versions, v)
}
return versions
}
Expand Down
28 changes: 15 additions & 13 deletions src/crypto/tls/handshake_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,26 +357,26 @@ func (hs *serverHandshakeState) checkForResumption() bool {
if plaintext == nil {
return false
}
hs.sessionState = &sessionState{usedOldKey: usedOldKey}
ok := hs.sessionState.unmarshal(plaintext)
clientSessionState := &sessionState{usedOldKey: usedOldKey}
ok := clientSessionState.unmarshal(plaintext)
if !ok {
return false
}

createdAt := time.Unix(int64(hs.sessionState.createdAt), 0)
createdAt := time.Unix(int64(clientSessionState.createdAt), 0)
if c.config.time().Sub(createdAt) > maxSessionTicketLifetime {
return false
}

// Never resume a session for a different TLS version.
if c.vers != hs.sessionState.vers {
if c.vers != clientSessionState.vers {
return false
}

cipherSuiteOk := false
// Check that the client is still offering the ciphersuite in the session.
for _, id := range hs.clientHello.cipherSuites {
if id == hs.sessionState.cipherSuite {
if id == clientSessionState.cipherSuite {
cipherSuiteOk = true
break
}
Expand All @@ -385,14 +385,7 @@ func (hs *serverHandshakeState) checkForResumption() bool {
return false
}

// Check that we also support the ciphersuite from the session.
hs.suite = selectCipherSuite([]uint16{hs.sessionState.cipherSuite},
c.config.cipherSuites(), hs.cipherSuiteOk)
if hs.suite == nil {
return false
}

sessionHasClientCerts := len(hs.sessionState.certificates) != 0
sessionHasClientCerts := len(clientSessionState.certificates) != 0
needClientCerts := requiresClientCert(c.config.ClientAuth)
if needClientCerts && !sessionHasClientCerts {
return false
Expand All @@ -401,6 +394,15 @@ func (hs *serverHandshakeState) checkForResumption() bool {
return false
}

// Check that we also support the ciphersuite from the session.
hs.suite = selectCipherSuite([]uint16{clientSessionState.cipherSuite},
c.config.cipherSuites(), hs.cipherSuiteOk)
if hs.suite == nil {
return false
}

hs.sessionState = clientSessionState

return true
}

Expand Down