Skip to content

Commit

Permalink
Handle no shared ciphers more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Dukhovni committed Dec 1, 2016
1 parent 82fb725 commit 620dfe2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions core/Network/TLS/Handshake/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,16 @@ handshakeServerWith sparams ctx clientHello@(ClientHello clientVersion _ clientS

extraCreds <- (onServerNameIndication $ serverHooks sparams) serverName

-- The shared cipherlist can become empty after filtering for compatible
-- creds, check now before calling onCipherChoosing, which does not handle
-- empty lists.
let ciphersFilteredVersion = filter (cipherAllowedForVersion chosenVersion) (commonCiphers extraCreds)
usedCipher = (onCipherChoosing $ serverHooks sparams) chosenVersion ciphersFilteredVersion
creds = extraCreds `mappend` (sharedCredentials $ ctxShared ctx)

when (commonCipherIDs extraCreds == []) $ throwCore $
when (null ciphersFilteredVersion) $ throwCore $
Error_Protocol ("no cipher in common with the client", True, HandshakeFailure)

let usedCipher = (onCipherChoosing $ serverHooks sparams) chosenVersion ciphersFilteredVersion
creds = extraCreds `mappend` (sharedCredentials $ ctxShared ctx)

cred <- case cipherKeyExchange usedCipher of
CipherKeyExchange_RSA -> return $ credentialsFindForDecrypting creds
CipherKeyExchange_DH_Anon -> return $ Nothing
Expand Down

0 comments on commit 620dfe2

Please sign in to comment.