Skip to content

Commit

Permalink
add support for overriding the TLS clientSupported member in TLSSetti…
Browse files Browse the repository at this point in the history
…ngsSimple

This is so we can manipulate these TLS settings even when using a connection
manager like the http-client package does. See
kazu-yamamoto#2 for details.
  • Loading branch information
bfrk committed May 15, 2024
1 parent 4dbfb2f commit 38d838e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Network/Connection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ initConnectionContext = ConnectionContext <$> getSystemCertificateStore
makeTLSParams :: ConnectionContext -> ConnectionID -> TLSSettings -> TLS.ClientParams
makeTLSParams cg cid ts@(TLSSettingsSimple {}) =
(TLS.defaultParamsClient (fst cid) portString)
{ TLS.clientSupported = def { TLS.supportedCiphers = TLS.ciphersuite_default }
{ TLS.clientSupported =
case settingClientSupported ts of
Nothing -> def { TLS.supportedCiphers = TLS.ciphersuite_default }
Just cs -> cs
, TLS.clientShared = def
{ TLS.sharedCAStore = globalCertificateStore cg
, TLS.sharedValidationCache = validationCache
Expand Down
5 changes: 4 additions & 1 deletion Network/Connection/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ data TLSSettings
-- will always re-established their context.
-- Not Implemented Yet.
, settingUseServerName :: Bool -- ^ Use server name extension. Not Implemented Yet.
, settingClientSupported :: Maybe TLS.Supported
-- ^ Override defaults for the 'TLS.clientSupported'
-- member of 'TLS.ClientParams'.
} -- ^ Simple TLS settings. recommended to use.
| TLSSettings TLS.ClientParams -- ^ full blown TLS Settings directly using TLS.Params. for power users.
deriving (Show)

instance Default TLSSettings where
def = TLSSettingsSimple False False False
def = TLSSettingsSimple False False False Nothing

type ConnectionID = (HostName, PortNumber)

Expand Down

0 comments on commit 38d838e

Please sign in to comment.