@@ -22,15 +22,16 @@ barely tested. The current implementation doesn't verify server's identity.
22
22
It only allows you to connect to a mongodb server using TLS protocol.
23
23
-}
24
24
module Database.MongoDB.Transport.Tls
25
- (connect)
25
+ ( connect
26
+ , connectWithTlsParams
27
+ )
26
28
where
27
29
28
30
import Data.IORef
29
- import Data.Monoid
31
+
30
32
import qualified Data.ByteString as ByteString
31
33
import qualified Data.ByteString.Lazy as Lazy.ByteString
32
34
import Data.Default.Class (def )
33
- import Control.Applicative ((<$>) )
34
35
import Control.Exception (bracketOnError )
35
36
import Control.Monad (when , unless )
36
37
import System.IO
@@ -45,15 +46,19 @@ import Database.MongoDB.Query (access, slaveOk, retrieveServerData)
45
46
46
47
-- | Connect to mongodb using TLS
47
48
connect :: HostName -> PortID -> IO Pipe
48
- connect host port = bracketOnError (connectTo host port) hClose $ \ handle -> do
49
-
50
- let params = (TLS. defaultParamsClient host " " )
49
+ connect host port = connectWithTlsParams params host port
50
+ where
51
+ params = (TLS. defaultParamsClient host " " )
51
52
{ TLS. clientSupported = def
52
- { TLS. supportedCiphers = TLS. ciphersuite_default}
53
+ { TLS. supportedCiphers = TLS. ciphersuite_default }
53
54
, TLS. clientHooks = def
54
- { TLS. onServerCertificate = \ _ _ _ _ -> return [] }
55
+ { TLS. onServerCertificate = \ _ _ _ _ -> return [] }
55
56
}
56
- context <- TLS. contextNew handle params
57
+
58
+ -- | Connect to mongodb using TLS using provided TLS client parameters
59
+ connectWithTlsParams :: TLS. ClientParams -> HostName -> PortID -> IO Pipe
60
+ connectWithTlsParams clientParams host port = bracketOnError (connectTo host port) hClose $ \ handle -> do
61
+ context <- TLS. contextNew handle clientParams
57
62
TLS. handshake context
58
63
59
64
conn <- tlsConnection context
0 commit comments