Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing ALPN #411

Merged
merged 3 commits into from
Dec 29, 2019
Merged
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
7 changes: 4 additions & 3 deletions core/Network/TLS/Handshake/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ doHandshake13 sparams ctx chosenVersion usedCipher exts usedHash clientKeyShare
setClientSupportsPHA supportsPHA
usingHState ctx $ setNegotiatedGroup $ keyShareEntryGroup clientKeyShare
srand <- setServerParameter
-- ALPN is used in choosePSK
protoExt <- applicationProtocol ctx exts sparams
(psk, binderInfo, is0RTTvalid) <- choosePSK
earlyKey <- calculateEarlySecret ctx choice (Left psk) True
let earlySecret = pairBase earlyKey
Expand Down Expand Up @@ -736,7 +738,7 @@ doHandshake13 sparams ctx chosenVersion usedCipher exts usedHash clientKeyShare
setRxState ctx usedHash usedCipher $ if rtt0OK then clientEarlySecret else clientHandshakeSecret
setTxState ctx usedHash usedCipher serverHandshakeSecret
----------------------------------------------------------------
sendExtensions rtt0OK
sendExtensions rtt0OK protoExt
case mCredInfo of
Nothing -> return ()
Just (cred, hashSig) -> sendCertAndVerify cred hashSig
Expand Down Expand Up @@ -887,8 +889,7 @@ doHandshake13 sparams ctx chosenVersion usedCipher exts usedHash clientKeyShare
vrfy <- makeCertVerify ctx pubkey hashSig hChSc
loadPacket13 ctx $ Handshake13 [vrfy]

sendExtensions rtt0OK = do
protoExt <- liftIO $ applicationProtocol ctx exts sparams
sendExtensions rtt0OK protoExt = do
msni <- liftIO $ usingState_ ctx getClientSNI
let sniExtension = case msni of
-- RFC6066: In this event, the server SHALL include
Expand Down
11 changes: 10 additions & 1 deletion core/Tests/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,17 @@ prop_handshake13_rtt0 = do
{ supportedCiphers = [cipher_TLS13_AES128GCM_SHA256]
, supportedGroups = [X25519]
}
params0 = (cli { clientSupported = cliSupported }
cliHooks = def {
onSuggestALPN = return $ Just ["h2"]
}
svrHooks = def {
onALPNClientSuggest = Just (\protos -> return $ head protos)
}
params0 = (cli { clientSupported = cliSupported
, clientHooks = cliHooks
}
,srv { serverSupported = svrSupported
, serverHooks = svrHooks
, serverEarlyDataSize = 2048 }
)

Expand Down