-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | OpenSSL network support for io-streams.
--   
--   The openssl-streams library contains io-streams routines for secure
--   networking using OpenSSL (by way of HsOpenSSL).
@package openssl-streams
@version 1.2.3.0

-- | This module provides convenience functions for interfacing
--   io-streams with HsOpenSSL. It is intended to be
--   imported qualified, e.g.:
--   
--   
--   import qualified OpenSSL as SSL
--   import qualified OpenSSL.Session as SSL
--   import qualified System.IO.Streams.SSL as SSLStreams
--   
--    example :: IO (InputStream ByteString, OutputStream ByteString)
--   example = SSL.withOpenSSL $ do
--       ctx <- SSL.context
--       SSL.contextSetDefaultCiphers ctx
--   
--        -- Note: the location of the system certificates is system-dependent,
--       -- on Linux systems this is usually "/etc/ssl/certs". This
--       -- step is optional if you choose to disable certificate verification
--       -- (not recommended!).
--       SSL.contextSetCADirectory ctx "/etc/ssl/certs"
--       SSL.contextSetVerificationMode ctx $
--           SSL.VerifyPeer True True Nothing
--       SSLStreams.connect ctx "foo.com" 4444
--   
module System.IO.Streams.SSL

-- | Convenience function for initiating an SSL connection to the given
--   (HostName, PortNumber) combination.
--   
--   Note that sending an end-of-file to the returned OutputStream
--   will not close the underlying SSL connection; to do that, call:
--   
--   
--   SSL.shutdown ssl SSL.Unidirectional
--   maybe (return ()) close $ SSL.sslSocket ssl
--   
--   
--   on the returned SSL object.
connect :: SSLContext -> HostName -> PortNumber -> IO (InputStream ByteString, OutputStream ByteString, SSL)

-- | Convenience function for initiating an SSL connection to the given
--   (HostName, PortNumber) combination. The socket
--   and SSL connection are closed and deleted after the user handler runs.
--   
--   Since: 1.2.0.0.
withConnection :: SSLContext -> HostName -> PortNumber -> (InputStream ByteString -> OutputStream ByteString -> SSL -> IO a) -> IO a

-- | Given an existing HsOpenSSL SSL connection, produces an
--   InputStream / OutputStream pair.
sslToStreams :: SSL -> IO (InputStream ByteString, OutputStream ByteString)
