| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
System.IO.Streams.OpenSSL
Description
This module provides convenience functions for interfacing io-streams
with HsOpenSSL. ssl/SSL here stand for HsOpenSSL library, not the
deprecated SSL 2.0/3.0 protocol. the receive buffer size is 32752.
sending is unbuffered, anything write into OutputStream will be immediately
send to underlying socket.
You should handle IOError when you read/write these streams for safety.
Be sure to use withOpenSSL wrap your operation before using any functions here.
otherwise a segmentation fault will happen.
- connect :: SSLContext -> Maybe String -> HostName -> PortNumber -> IO (InputStream ByteString, OutputStream ByteString, SSL)
- withConnection :: SSLContext -> Maybe String -> HostName -> PortNumber -> (InputStream ByteString -> OutputStream ByteString -> SSL -> IO a) -> IO a
- accept :: SSLContext -> Socket -> IO (InputStream ByteString, OutputStream ByteString, SSL, SockAddr)
- withOpenSSL :: IO a -> IO a
- sslToStreams :: SSL -> IO (InputStream ByteString, OutputStream ByteString)
- closeSSL :: SSL -> IO ()
- data CertificateVerifyFail = CertificateVerifyFail
client
Arguments
| :: SSLContext | SSL context. See the |
| -> Maybe String | Optional certificate subject name, if set to |
| -> HostName | hostname to connect to |
| -> PortNumber | port number to connect to |
| -> IO (InputStream ByteString, OutputStream ByteString, SSL) |
Convenience function for initiating an SSL connection to the given
( combination.HostName, PortNumber)
this function will try to verify server's identity,
a CertificateVerifyFail will be thrown if fail.
it may throw SomeSSLException too.
Arguments
| :: SSLContext | |
| -> Maybe String | |
| -> HostName | |
| -> PortNumber | |
| -> (InputStream ByteString -> OutputStream ByteString -> SSL -> IO a) | Action to run with the new connection |
| -> IO a |
Convenience function for initiating an SSL connection to the given
( combination. The socket and SSL connection are
closed and deleted after the user handler runs.HostName, PortNumber)
server
Arguments
| :: SSLContext | check Data.OpenSSLSetting. |
| -> Socket | the listening |
| -> IO (InputStream ByteString, OutputStream ByteString, SSL, SockAddr) |
accept a new connection from remote client, return a InputStream / OutputStream
pair and remote SockAddr, you should call bindAndListen first.
this operation will throw SomeSSLException on failure.
helpers
withOpenSSL :: IO a -> IO a #
Computation of initializes the OpenSSL
library as necessary, and computes withOpenSSL actionaction. Every application that
uses HsOpenSSL must wrap any operations involving OpenSSL with
withOpenSSL, or they might crash:
module Main where
import OpenSSL
main :: IO ()
main = withOpenSSL $
do ...Since 0.10.3.5, withOpenSSL is safe to be applied
redundantly. Library authors may wish to wrap their functions not
to force their users to think about initialization:
get :: URI -> IO Response get uri = withOpenSSL $ internalImplementationOfGet uri
Arguments
| :: SSL | SSL connection object |
| -> IO (InputStream ByteString, OutputStream ByteString) |
Given an existing HsOpenSSL SSL connection, produces an InputStream /
OutputStream pair.
data CertificateVerifyFail Source #
Constructors
| CertificateVerifyFail |