packages feed

tls 2.6.2 → 2.6.3

raw patch · 13 files changed

+309/−22 lines, 13 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,18 @@ # Change log for "tls" +## Version 2.6.3++* Never wrap around the RTT of a ticket, and cap it at 10 seconds.+  [#661](https://github.com/haskell-tls/hs-tls/pull/661)+* Keep contexts closable after failures of the backend.+  [#663](https://github.com/haskell-tls/hs-tls/pull/663)+* bye neither sends nor waits after a failed send.+  [#664](https://github.com/haskell-tls/hs-tls/pull/664)+* Throw the exception of a failed send again on later sends.+  [#665](https://github.com/haskell-tls/hs-tls/pull/665)+* bye sends close_notify when the backend gives up by itself.+  [#666](https://github.com/haskell-tls/hs-tls/pull/666)+ ## Version 2.6.2  * Make bye robust after a failed handshake or a vanished peer.
Network/TLS/Backend.hs view
@@ -36,6 +36,13 @@     , backendRecv :: Int -> IO ByteString     -- ^ Receive the specified number of bytes from the connection.     -- Fewer bytes are returned only at the end of the stream.+    --+    -- An 'Control.Exception.IOException' means a broken connection: the+    -- context is marked EOF and 'Network.TLS.bye' sends nothing.  Other+    -- exceptions, including asynchronous ones, pass through as they are,+    -- and 'Network.TLS.bye' can still send close_notify.  'Network.TLS.recvData'+    -- may be called again only if the exception was thrown before any byte+    -- of a record was taken; otherwise the stream is left inside the record.     }  -- | Types which a 'Network.TLS.Context' can be created on.
Network/TLS/Context.hs view
@@ -174,6 +174,7 @@     tlsstate <- newMVar st     eof <- newIORef False     closeNotify <- newIORef False+    txBroken <- newIORef Nothing     established <- newIORef NotEstablished     stats <- newIORef newMeasurement     needEmptyPacket <- newIORef False@@ -215,6 +216,7 @@                 , ctxMeasurement = stats                 , ctxEOF_ = eof                 , ctxCloseNotify_ = closeNotify+                , ctxTxBroken_ = txBroken                 , ctxEstablished_ = established                 , ctxNeedEmptyPacket = needEmptyPacket                 , ctxHooks = hooks
Network/TLS/Context/Internal.hs view
@@ -24,12 +24,15 @@     RoleParams (..),     ctxEOF,     ctxCloseNotify,+    ctxTxBroken,+    ctxTxBrokenBy,     ctxEstablished,     withLog,     ctxWithHooks,     contextModifyHooks,     setEOF,     setCloseNotify,+    setTxBroken,     setEstablished,     skipEarlyData,     contextFlush,@@ -139,6 +142,9 @@     -- ^ has the handle EOFed or not.     , ctxCloseNotify_ :: IORef Bool     -- ^ has close_notify been received or not.+    , ctxTxBroken_ :: IORef (Maybe E.SomeException)+    -- ^ the exception of the first failed send, which left the TX record+    -- state ahead of the peer.     , ctxEstablished_ :: IORef Established     -- ^ has the handshake been done and been successful.     , ctxTxRecordState :: MVar RecordState@@ -436,6 +442,15 @@  setCloseNotify :: Context -> IO () setCloseNotify ctx = writeIORef (ctxCloseNotify_ ctx) True++ctxTxBroken :: Context -> IO Bool+ctxTxBroken ctx = isJust <$> ctxTxBrokenBy ctx++ctxTxBrokenBy :: Context -> IO (Maybe E.SomeException)+ctxTxBrokenBy ctx = readIORef $ ctxTxBroken_ ctx++setTxBroken :: Context -> E.SomeException -> IO ()+setTxBroken ctx e = atomicModifyIORef' (ctxTxBroken_ ctx) $ \m -> (m <|> Just e, ())  ctxEstablished :: Context -> IO Established ctxEstablished ctx = readIORef $ ctxEstablished_ ctx
Network/TLS/Core.hs view
@@ -45,6 +45,7 @@ import Network.TLS.Context import Network.TLS.Context.Internal (     PHAResult (..),+    ctxTxBroken,     incrementTLS13KeyUpdateCount,     resetTLS13KeyUpdateCount,  )@@ -69,6 +70,7 @@     Bulk (..),     Cipher (..),     HostName,+    Millisecond,     Role (..),  ) import Network.TLS.Util (catchException, mapChunks_)@@ -126,10 +128,15 @@ rttFactor :: Int rttFactor = 3 +-- | An upper bound of the RTT measured in the handshake, which sets how+-- long to wait for the peer.+maxWaitRTT :: Millisecond+maxWaitRTT = 1000+ getRTT :: Context -> IO Int getRTT ctx = do     rtt <- tls13stRTT <$> getTLS13State ctx-    let rtt' = max (fromIntegral rtt) 10+    let rtt' = max 10 $ fromIntegral $ min maxWaitRTT rtt     return (rtt' * rttFactor * 1000) -- ms to us  -- | Notify the peer that this side wants to close the connection, by@@ -153,8 +160,10 @@ bye :: MonadIO m => Context -> m () bye ctx = liftIO $ do     eof <- ctxEOF ctx+    -- After a failed send, nothing is sent, so nothing is waited for either.+    broken <- ctxTxBroken ctx     tls13 <- tls13orLater ctx-    when (tls13 && not eof) $ do+    when (tls13 && not eof && not broken) $ do         role <- usingState_ ctx getRole         if role == ClientRole             then do@@ -201,14 +210,20 @@         Just (RecvWith recvWith) -> do             late <- registerDelay rtt             let giveUp = readTVar late >>= check-                recv n = recvWith n giveUp >>= either (\() -> E.throwIO GaveUpRecv) return+                -- Bytes received before giving up are not the end of the stream.+                recv n = do+                    r <- recvWith n giveUp+                    expired <- readTVarIO late+                    case r of+                        Right bs | B.length bs == n || not expired -> return bs+                        _ -> E.throwIO GaveUpRecv                 ctx' = ctx{ctxBackend = (ctxBackend ctx){backendRecv = recv}}             void $                 tryWithReadLock ctx $                     recvHS13 ctx' chk `catchException` \e ->-                        -- If the receive failed rather than gave up, the-                        -- connection is gone and close_notify is not sent.-                        when (isNothing (E.fromException @GaveUpRecv e)) $+                        -- Only an IOException means that the connection is gone+                        -- (see 'backendRecv'); otherwise close_notify is sent.+                        when (isJust (E.fromException @E.IOException e)) $                             setEOF ctx  -- | Thrown by a receive in 'bye' which has given up, and caught there.@@ -222,8 +237,9 @@     -- to wrap ctxEOF with it, so that function bye can still be called     -- concurrently to a blocked recvData.     eof <- ctxEOF ctx+    broken <- ctxTxBroken ctx     tls13 <- tls13orLater ctx-    unless eof $+    unless (eof || broken) $         E.handleJust vanished return $             withWriteLock ctx $                 if tls13@@ -316,6 +332,9 @@ -- ClientHello is received.  An empty result means EOF, after which it -- throws 'PostHandshake' 'Error_EOF'.  Use 'closeNotifyReceived' to tell -- an orderly closure from a truncation.+--+-- An exception from the backend's receive passes through.  See+-- 'Network.TLS.backendRecv' for when it may be called again. recvData :: MonadIO m => Context -> m ByteString recvData ctx = liftIO $ do     tls13 <- tls13orLater ctx@@ -344,7 +363,7 @@     -- UserCanceled should be followed by a close_notify.     -- fixme: is it safe to call recvData12?     process (Alert [(AlertLevel_Warning, UserCanceled)]) = return B.empty-    process (Alert [(AlertLevel_Warning, CloseNotify)]) = setCloseNotify ctx >> tryBye ctx >> setEOF ctx >> return B.empty+    process (Alert [(AlertLevel_Warning, CloseNotify)]) = setCloseNotify ctx >> tryBye ctx >> return B.empty     process (Alert [(AlertLevel_Fatal, desc)]) = do         setEOF ctx         E.throwIO@@ -393,7 +412,7 @@     -- closure ones are error alerts, even at the warning level.     -- UserCanceled MUST be followed by a CloseNotify.     process (Alert13 [(_, UserCanceled)]) = return B.empty-    process (Alert13 [(_, CloseNotify)]) = setCloseNotify ctx >> tryBye ctx >> setEOF ctx >> return B.empty+    process (Alert13 [(_, CloseNotify)]) = setCloseNotify ctx >> tryBye ctx >> return B.empty     process (Alert13 [(_, desc)]) = do         setEOF ctx         E.throwIO@@ -532,7 +551,7 @@   where     -- UserCanceled MUST be followed by a CloseNotify.     process (Alert13 [(_, UserCanceled)]) = recvHS13 ctx breakLoop-    process (Alert13 [(_, CloseNotify)]) = setCloseNotify ctx >> tryBye ctx >> setEOF ctx+    process (Alert13 [(_, CloseNotify)]) = setCloseNotify ctx >> tryBye ctx     process (Alert13 [(_, _desc)]) = setEOF ctx     process (Handshake13 hs bs) = do         loopHandshake13 $ zip hs bs@@ -631,7 +650,7 @@ -- the other side could have close the connection already, so wrap -- this in a try and ignore all exceptions tryBye :: Context -> IO ()-tryBye ctx = catchException (bye_ ctx) (\_ -> return ())+tryBye ctx = catchException (bye_ ctx) (\_ -> return ()) `E.finally` setEOF ctx  onError     :: Monad m
Network/TLS/Handshake/Common.hs view
@@ -87,7 +87,8 @@             _ -> Error_Misc (show exception)     established <- ctxEstablished ctx     setEstablished ctx NotEstablished-    E.handle ignoreIOErr $ do+    -- A failure of the send, whatever it is, must not skip 'setEOF'.+    (`catchException` \_ -> return ()) $ do         tls13 <- tls13orLater ctx         if tls13             then do@@ -100,9 +101,6 @@     -- Both callers hold the read lock.     setEOF ctx     handshakeFailed tlserror-  where-    ignoreIOErr :: E.IOException -> IO ()-    ignoreIOErr _ = return ()  errorToAlert :: TLSError -> (AlertLevel, AlertDescription) errorToAlert (Error_Protocol _ ad) = (AlertLevel_Fatal, ad)
Network/TLS/Handshake/Common13.hs view
@@ -21,6 +21,7 @@     isAgeValid,     getAge,     checkFreshness,+    maxRTT,     getCurrentTimeFromBase,     getSessionData13,     isHashSignatureValid13,@@ -325,7 +326,11 @@ getAge TLS13TicketInfo{..} = do     let clientReceiveTime = txrxTime     clientSendTime <- getCurrentTimeFromBase-    return $ fromIntegral (clientSendTime - clientReceiveTime) -- milliseconds+    -- The wall clock can go back, which must not wrap the age around.+    return $+        if clientSendTime > clientReceiveTime+            then fromIntegral (clientSendTime - clientReceiveTime) -- milliseconds+            else 0  checkFreshness :: TLS13TicketInfo -> Second -> IO Bool checkFreshness tinfo@TLS13TicketInfo{..} obfAge = do@@ -341,10 +346,16 @@     return $ isAlive && isFresh   where     serverSendTime = txrxTime-    rtt = fromJust estimatedRTT+    -- Capped also for a ticket issued before the RTT was capped.+    rtt = min maxRTT $ fromJust estimatedRTT     age = obfuscatedAgeToAge obfAge tinfo     expectedArrivalTime = serverSendTime + rtt + fromIntegral age     isAlive = isAgeValid age tinfo++-- | The RTT kept in a ticket is capped: it widens the tolerance of the+-- freshness check, and the client can delay its Finished to inflate it.+maxRTT :: Millisecond+maxRTT = 10000  getCurrentTimeFromBase :: IO Millisecond getCurrentTimeFromBase = millisecondsFromBase <$> getUnixTime
Network/TLS/Handshake/Server/TLS13.hs view
@@ -146,7 +146,10 @@     -> IO () sendNewSessionTicket sparams ctx usedCipher exts applicationSecret sfSentTime = when sendNST $ do     cfRecvTime <- getCurrentTimeFromBase-    let rtt = cfRecvTime - sfSentTime+    -- The wall clock can go back, which must not wrap the RTT around.+    let rtt+            | cfRecvTime > sfSentTime = min maxRTT $ cfRecvTime - sfSentTime+            | otherwise = 0     nonce <- TicketNonce <$> getStateRNG ctx 32     resumptionSecret <- calculateResumptionSecret ctx choice applicationSecret     let life = adjustLifetime $ serverTicketLifetime sparams
Network/TLS/PostHandshake.hs view
@@ -40,6 +40,12 @@ -- 'False' it returns 'PHAPending' meanwhile.  Only one request may be -- pending.  'Network.TLS.getClientCertificateChain' gives the authenticated chain. -- Server only.+--+-- The blocking wait ends with the response or with the end of the+-- connection, e.g. a received alert or an 'Control.Exception.IOException'+-- from the backend.  It waits as long as the client does not respond,+-- and while 'Network.TLS.recvData' is stopped by another exception, so+-- put a timeout on it if needed. requestCertificateAsync :: Context -> IO (Bool -> IO PHAResult) requestCertificateAsync ctx =     checkValid ctx >> doRequestCertificateAsync_ (ctxRoleParams ctx) ctx
Network/TLS/Record/Send.hs view
@@ -6,6 +6,7 @@ ) where  import Control.Concurrent.MVar+import qualified Control.Exception as E import Control.Monad.State.Strict import qualified Data.ByteString as B @@ -57,5 +58,14 @@  sendBytes :: Context -> ByteString -> IO () sendBytes ctx dataToSend = do+    -- The record state has advanced already, so a failed send leaves the+    -- peer unable to decrypt any later record.  Later sends throw the same+    -- exception, except an asynchronous one, which is not thrown again.+    ctxTxBrokenBy ctx >>= mapM_ (\e -> E.throwIO $ fromMaybe e $ asTLS e)     withLog ctx $ \logging -> loggingIOSent logging dataToSend-    contextSend ctx dataToSend+    contextSend ctx dataToSend `E.catch` \e -> setTxBroken ctx e >> E.throwIO e+  where+    asTLS e = case E.fromException e of+        Just (E.SomeAsyncException _) ->+            Just $ E.toException $ PostHandshake $ Error_Misc "a previous send failed"+        Nothing -> Nothing
test/ByeSpec.hs view
@@ -10,8 +10,10 @@ import qualified Control.Exception as E import Control.Monad (when) import Data.ByteString (ByteString)+import qualified Data.ByteString as B import Data.Either (isLeft) import Data.IORef+import GHC.Clock (getMonotonicTime) import qualified Network.Socket as N import qualified Network.Socket.ByteString as NB import Network.TLS@@ -41,6 +43,22 @@             `shouldReturn` Just ((), mempty)         readIORef used `shouldReturn` True +    it "sends close_notify when the backend gives up by itself" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        let noop = return ()+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)+            sBackend = Backend noop noop (writePipeS pipe) (readPipeS pipe)+            -- e.g. on shutdown, without waiting for 'bye' to give up+            shutdown = RecvWith $ \_ _ -> E.throwIO $ E.ErrorCall "shutdown"+        cCtx <- contextNew (GivingUp cBackend shutdown) cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        timeout 5000000 (concurrently (bye cCtx) (recvData sCtx))+            `shouldReturn` Just ((), mempty)+        closeNotifyReceived sCtx `shouldReturn` True+     it "gives up on a receive over a socket" $ do #if MIN_VERSION_network(3,2,12)         (cs, ss) <- N.socketPair N.AF_UNIX N.Stream N.defaultProtocol@@ -115,6 +133,152 @@         N.close ss         timeout 5000000 (bye cCtx) `shouldReturn` Just ()         N.close cs++    it "sends close_notify when the last handshake message is cut short" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        let noop = return ()+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)+            sBackend = Backend noop noop (writePipeS pipe) (readPipeS pipe)+            -- Half of a record body arrives before giving up.+            cut = RecvWith $ \n giveUp -> do+                bs <- readPipeC pipe n+                if n == 5+                    then return $ Right bs+                    else atomically giveUp >> return (Right $ B.take (n `div` 2) bs)+        cCtx <- contextNew (GivingUp cBackend cut) cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        timeout 5000000 (concurrently (bye cCtx) (recvData sCtx))+            `shouldReturn` Just ((), mempty)+        closeNotifyReceived sCtx `shouldReturn` True++    it "waits for the last handshake messages a few seconds at most" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        sent <- newIORef False+        let noop = return ()+            -- Every answer is late, which makes the RTT two seconds.+            sendC bs = writeIORef sent True >> writePipeC pipe bs+            recvC n = do+                s <- atomicModifyIORef' sent (\x -> (False, x))+                when s $ threadDelay 2000000+                readPipeC pipe n+            cBackend = Backend noop noop sendC recvC+            sBackend = Backend noop noop (writePipeS pipe) (readPipeS pipe)+            never = RecvWith $ \_ giveUp -> Left <$> atomically giveUp+        cCtx <- contextNew (GivingUp cBackend never) cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        t0 <- getMonotonicTime+        bye cCtx+        t1 <- getMonotonicTime+        (t1 - t0) `shouldSatisfy` (< 4)++    it "sends nothing after a failed send" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        failing <- newIORef False+        sent <- newIORef (0 :: Int)+        let noop = return ()+            sendS bs = do+                f <- readIORef failing+                when f $ E.throwIO E.ThreadKilled+                modifyIORef' sent (+ 1)+                writePipeS pipe bs+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)+            sBackend = Backend noop noop sendS (readPipeS pipe)+        cCtx <- contextNew cBackend cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        writeIORef failing True+        E.try @E.AsyncException (sendData sCtx "abc") `shouldReturn` Left E.ThreadKilled+        writeIORef failing False+        -- An asynchronous exception is not thrown again.+        E.try @TLSException (sendData sCtx "abc") `shouldReturn` Left (PostHandshake (Error_Misc "a previous send failed"))+        n <- readIORef sent+        timeout 5000000 (bye sCtx) `shouldReturn` Just ()+        readIORef sent `shouldReturn` n++    it "throws the exception of the failed send again" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        failing <- newIORef False+        let noop = return ()+            sendS bs = do+                f <- atomicModifyIORef' failing (\x -> (False, x))+                when f $ E.throwIO $ E.ErrorCall "broken"+                writePipeS pipe bs+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)+            sBackend = Backend noop noop sendS (readPipeS pipe)+        cCtx <- contextNew cBackend cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        writeIORef failing True+        E.try (sendData sCtx "abc") `shouldReturn` Left (E.ErrorCall "broken")+        E.try (sendData sCtx "abc") `shouldReturn` Left (E.ErrorCall "broken")++    it "does not wait after a failed send" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        failing <- newIORef False+        used <- newIORef False+        let noop = return ()+            sendC bs = do+                f <- readIORef failing+                when f $ E.throwIO E.ThreadKilled+                writePipeC pipe bs+            cBackend = Backend noop noop sendC (readPipeC pipe)+            sBackend = Backend noop noop (writePipeS pipe) (readPipeS pipe)+        cCtx <-+            contextNew (GivingUp cBackend $ recvWithVia (readPipeC pipe) used) cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        writeIORef failing True+        E.try @E.AsyncException (sendData cCtx "abc") `shouldReturn` Left E.ThreadKilled+        timeout 5000000 (bye cCtx) `shouldReturn` Just ()+        readIORef used `shouldReturn` False++    it "sends nothing after a handshake whose send failed" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        let noop = return ()+            broken _ = E.throwIO $ E.ErrorCall "broken"+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)+            sBackend = Backend noop noop broken (readPipeS pipe)+        cCtx <- contextNew cBackend cParams+        sCtx <- contextNew sBackend sParams+        withAsync (handshake cCtx) $ \_ -> do+            r <- E.try @TLSException $ handshake sCtx+            r `shouldSatisfy` isLeft+            timeout 5000000 (bye sCtx) `shouldReturn` Just ()++    it "ends the connection when the answer to close_notify fails" $ do+        (cParams, sParams) <- generate arbitraryPairParams13+        pipe <- newPipe+        _ <- runPipe pipe+        failing <- newIORef False+        let noop = return ()+            sendS bs = do+                f <- readIORef failing+                when f $ E.throwIO E.ThreadKilled+                writePipeS pipe bs+            cBackend = Backend noop noop (writePipeC pipe) (readPipeC pipe)+            sBackend = Backend noop noop sendS (readPipeS pipe)+        cCtx <- contextNew cBackend cParams+        sCtx <- contextNew sBackend sParams+        concurrently_ (handshake cCtx) (handshake sCtx)+        writeIORef failing True+        withAsync (bye cCtx) $ \_ -> do+            E.try @E.AsyncException (recvData sCtx) `shouldReturn` Left E.ThreadKilled+            timeout 1000000 (E.try @TLSException (recvData sCtx))+                `shouldReturn` Just (Left (PostHandshake Error_EOF))  -- | A backend which can give up on a receive. data GivingUp = GivingUp Backend RecvWith
test/HandshakeSpec.hs view
@@ -255,6 +255,10 @@             handshake13_0rtt_only_once True         it "refuses 0RTT, not the resumption, when the session is used up" $             handshake13_0rtt_only_once False+        it "caps the RTT of a ticket in the freshness check" $+            handshake13_0rtt_wrapped_rtt+        it "sends the age 0 of a ticket received in the client's future" $+            handshake13_0rtt_client_clock_back         it "authenticates a server rejecting the PSK of 0RTT" $             handshake13_0rtt_psk_rejected False         it "authenticates a server rejecting the PSK of 0RTT, asking a cert" $@@ -3004,7 +3008,17 @@ -- with a verified binder.  A stale one falls back to a full handshake -- without it; a session it has used up already is resumed without 0RTT. handshake13_0rtt_only_once :: Bool -> IO ()-handshake13_0rtt_only_once stale = do+handshake13_0rtt_only_once stale = handshake13_0rtt_aged $ if stale then Just id else Nothing++-- | An RTT wrapped around by a wall clock going back does not make a stale+-- ticket fresh.+handshake13_0rtt_wrapped_rtt :: IO ()+handshake13_0rtt_wrapped_rtt =+    handshake13_0rtt_aged $ Just $ \t -> t{estimatedRTT = Just (maxBound - 4)}++-- | The client's clock went back by an hour after receiving the ticket.+handshake13_0rtt_client_clock_back :: IO ()+handshake13_0rtt_client_clock_back = do     (cli, srv) <- generate arbitraryPairParams13     let supported =             defaultSupported@@ -3017,6 +3031,31 @@             , srv{serverSupported = supported, serverEarlyDataSize = 2048}             )     sessionRefs <- twoSessionRefs+    let params = setPairParamsSessionManagers (twoSessionManagers sessionRefs) params0+    runTLSSimple13 params FullHandshake+    Just (sid, sdata) <- readClientSessionRef sessionRefs+    let future t = t{txrxTime = txrxTime t + 3600000}+        sdata' = sdata{sessionTicketInfo = future <$> sessionTicketInfo sdata}+        (pc, ps) = setPairParamsSessionResuming (sid, sdata') params+    runTLS0RTT (pc{clientUseEarlyData = True}, ps) RTT0 "early data"++-- | With 'Just', the ticket is made an hour old and modified further.+handshake13_0rtt_aged :: Maybe (TLS13TicketInfo -> TLS13TicketInfo) -> IO ()+handshake13_0rtt_aged mmodify = do+    let stale = isJust mmodify+        modify = fromMaybe id mmodify+    (cli, srv) <- generate arbitraryPairParams13+    let supported =+            defaultSupported+                { supportedCiphers = [cipher13_AES_128_GCM_SHA256]+                , supportedGroups = [X25519]+                , supportedGroupsTLS13 = [[X25519]]+                }+        params0 =+            ( cli{clientSupported = supported}+            , srv{serverSupported = supported, serverEarlyDataSize = 2048}+            )+    sessionRefs <- twoSessionRefs     let (cmgr, smgr) = twoSessionManagers sessionRefs         params = setPairParamsSessionManagers (cmgr, smgr) params0     runTLSSimple13 params FullHandshake@@ -3028,7 +3067,7 @@         age sdata =             sdata                 { sessionTicketInfo =-                    (\t -> t{txrxTime = txrxTime t - 3600000}) <$> sessionTicketInfo sdata+                    (\t -> modify t{txrxTime = txrxTime t - 3600000}) <$> sessionTicketInfo sdata                 }         resume' f sid             | stale = fmap age <$> f sid
tls.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.0 name:               tls-version:            2.6.2+version:            2.6.3 license:            BSD3 license-file:       LICENSE copyright:          Vincent Hanquez <vincent@snarc.org>