From 54aff363664aba374585985b1d7fb9d48d2cf352 Mon Sep 17 00:00:00 2001 From: rnons Date: Tue, 4 Mar 2014 20:51:17 +0800 Subject: [PATCH] Update to tls-1.2, drop the dependency of tls-extra. --- pontarius-xmpp.cabal | 3 +-- source/Network/Xmpp/Lens.hs | 4 ++-- source/Network/Xmpp/Tls.hs | 6 +++--- source/Network/Xmpp/Types.hs | 23 +++++++++++++---------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal index da1d218..5944822 100644 --- a/pontarius-xmpp.cabal +++ b/pontarius-xmpp.cabal @@ -65,8 +65,7 @@ Library , stm >=2.1.2.1 , stringprep >=1.0.0 , text >=0.11.1.5 - , tls >=1.1.3 - , tls-extra >=0.6.0 + , tls >=1.2 , transformers >=0.2.2.0 , unbounded-delays >=0.1 , void >=0.5.5 diff --git a/source/Network/Xmpp/Lens.hs b/source/Network/Xmpp/Lens.hs index 7aa1198..0454af6 100644 --- a/source/Network/Xmpp/Lens.hs +++ b/source/Network/Xmpp/Lens.hs @@ -105,7 +105,7 @@ import qualified Data.Text as Text import Data.Text(Text) import Data.XML.Types(Element) import Network.DNS(ResolvConf) -import Network.TLS (TLSParams) +import Network.TLS (ClientParams) import Network.Xmpp.Concurrent.Types import Network.Xmpp.IM.Roster.Types import Network.Xmpp.IM.Message @@ -390,7 +390,7 @@ tlsBehaviourL :: Lens StreamConfiguration TlsBehaviour tlsBehaviourL inj sc@StreamConfiguration{tlsBehaviour = x} = (\x' -> sc{tlsBehaviour = x'}) <$> inj x -tlsParamsL :: Lens StreamConfiguration TLSParams +tlsParamsL :: Lens StreamConfiguration ClientParams tlsParamsL inj sc@StreamConfiguration{tlsParams = x} = (\x' -> sc{tlsParams = x'}) <$> inj x diff --git a/source/Network/Xmpp/Tls.hs b/source/Network/Xmpp/Tls.hs index 638f4e4..d627986 100644 --- a/source/Network/Xmpp/Tls.hs +++ b/source/Network/Xmpp/Tls.hs @@ -107,12 +107,12 @@ tls con = fmap join -- We can have Left values both from exceptions and the modify (\s -> s{streamConnectionState = Secured}) return () -client :: (MonadIO m, CPRG rng) => Params -> rng -> Backend -> m Context +client :: (MonadIO m, CPRG rng) => ClientParams -> rng -> Backend -> m Context client params gen backend = do contextNew backend params gen tlsinit :: (MonadIO m, MonadIO m1) => - TLSParams + ClientParams -> Backend -> m ( Source m1 BS.ByteString , Sink BS.ByteString m1 () @@ -164,7 +164,7 @@ mkReadBuffer recv = do -- seem to use it. connectTls :: ResolvConf -- ^ Resolv conf to use (try 'defaultResolvConf' as a -- default) - -> TLSParams -- ^ TLS parameters to use when securing the connection + -> ClientParams -- ^ TLS parameters to use when securing the connection -> String -- ^ Host to use when connecting (will be resolved -- using SRV records) -> ErrorT XmppFailure IO StreamHandle diff --git a/source/Network/Xmpp/Types.hs b/source/Network/Xmpp/Types.hs index c62b5bc..ac73cb1 100644 --- a/source/Network/Xmpp/Types.hs +++ b/source/Network/Xmpp/Types.hs @@ -532,9 +532,9 @@ data StreamErrorInfo = StreamErrorInfo } deriving (Show, Eq) data XmppTlsError = XmppTlsError TLSError - | XmppTlsConnectionNotEstablished ConnectionNotEstablished - | XmppTlsTerminated Terminated - | XmppTlsHandshakeFailed HandshakeFailed + | XmppTlsConnectionNotEstablished TLSException + | XmppTlsTerminated TLSException + | XmppTlsHandshakeFailed TLSException deriving (Show, Eq, Typeable) -- | Signals an XMPP stream error or another unpredicted stream-related @@ -1179,16 +1179,19 @@ data StreamConfiguration = -- | How the client should behave in regards to TLS. , tlsBehaviour :: TlsBehaviour -- | Settings to be used for TLS negotitation - , tlsParams :: TLSParams + , tlsParams :: ClientParams } -- | Default parameters for TLS. Those are the default client parameters from the tls package with the ciphers set to ciphersuite_strong -xmppDefaultParams :: Params -xmppDefaultParams = defaultParamsClient{ pCiphers = ciphersuite_strong - ++ [ cipher_AES256_SHA1 - , cipher_AES128_SHA1 - ] - } +xmppDefaultParams :: ClientParams +xmppDefaultParams = (defaultParamsClient "" BS.empty) + { clientSupported = def + { supportedCiphers = ciphersuite_strong + ++ [ cipher_AES256_SHA1 + , cipher_AES128_SHA1 + ] + } + } instance Default StreamConfiguration where def = StreamConfiguration { preferredLang = Nothing