-- 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.1.1


-- | This module provides convenience functions for interfacing
--   <tt>io-streams</tt> with <tt>HsOpenSSL</tt>. It is intended to be
--   imported <tt>qualified</tt>, e.g.:
--   
--   <pre>
--   import qualified <a>OpenSSL</a> as SSL
--   import qualified <a>OpenSSL.Session</a> as SSL
--   import qualified <a>System.IO.Streams.SSL</a> as SSLStreams
--   
--    example :: IO (<a>InputStream</a> <a>ByteString</a>, <a>OutputStream</a> <a>ByteString</a>)
--   example = SSL.<a>withOpenSSL</a> $ do
--       ctx &lt;- SSL.<a>context</a>
--       SSL.<a>contextSetDefaultCiphers</a> 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.<a>contextSetCADirectory</a> ctx "/etc/ssl/certs"
--       SSL.<a>contextSetVerificationMode</a> ctx $
--           SSL.<a>VerifyPeer</a> True True Nothing
--       SSLStreams.<a>connect</a> ctx "foo.com" 4444
--   </pre>
module System.IO.Streams.SSL

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

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

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