tls-1.5.6: TLS/SSL protocol native implementation (Server and Client)

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Network.TLS

Contents

- Basic APIs
- Backend abstraction
- Parameters
  - Shared
  - Hooks
  - Supported
  - Debug parameters
- Shared parameters
  - Credentials
  - Session manager
  - Validation Cache
- Types
  - For `Supported`
  - For parameters and hooks
- Advanced APIs
  - Backend
  - Information gathering
  - Negotiated
  - Post-handshake actions
  - Modifying hooks in context
- Errors and exceptions
  - Errors
  - Exceptions
- Raw types
  - Compressions class
  - Crypto Key
  - Ciphers & Predefined ciphers
- Deprecated

Description

Native Haskell TLS and SSL protocol implementation for server and client.

This provides a high-level implementation of a sensitive security protocol, eliminating a common set of security issues through the use of the advanced type system, high level constructions and common Haskell features.

Currently implement the SSL3.0, TLS1.0, TLS1.1, TLS1.2 and TLS 1.3 protocol, and support RSA and Ephemeral (Elliptic curve and regular) Diffie Hellman key exchanges, and many extensions.

Some debug tools linked with tls, are available through the http://hackage.haskell.org/package/tls-debug/.

Synopsis

- data Context
- contextNew :: (MonadIO m, HasBackend backend, TLSParams params) => backend -> params -> m Context
- handshake :: MonadIO m => Context -> m ()
- sendData :: MonadIO m => Context -> ByteString -> m ()
- recvData :: MonadIO m => Context -> m ByteString
- bye :: MonadIO m => Context -> m ()
- class HasBackend a where
  - initializeBackend :: a -> IO ()
  - getBackend :: a -> Backend
- data Backend = Backend {
  - backendFlush :: IO ()
  - backendClose :: IO ()
  - backendSend :: ByteString -> IO ()
  - backendRecv :: Int -> IO ByteString
  }
- class TLSParams a
- data ClientParams = ClientParams {
  - clientUseMaxFragmentLength :: Maybe MaxFragmentEnum
  - clientServerIdentification :: (HostName, ByteString)
  - clientUseServerNameIndication :: Bool
  - clientWantSessionResume :: Maybe (SessionID, SessionData)
  - clientShared :: Shared
  - clientHooks :: ClientHooks
  - clientSupported :: Supported
  - clientDebug :: DebugParams
  - clientEarlyData :: Maybe ByteString
  }
- defaultParamsClient :: HostName -> ByteString -> ClientParams
- data ServerParams = ServerParams {
  - serverWantClientCert :: Bool
  - serverCACertificates :: [SignedCertificate]
  - serverDHEParams :: Maybe DHParams
  - serverHooks :: ServerHooks
  - serverShared :: Shared
  - serverSupported :: Supported
  - serverDebug :: DebugParams
  - serverEarlyDataSize :: Int
  - serverTicketLifetime :: Int
  }
- data Shared = Shared {
  - sharedCredentials :: Credentials
  - sharedSessionManager :: SessionManager
  - sharedCAStore :: CertificateStore
  - sharedValidationCache :: ValidationCache
  - sharedHelloExtensions :: [ExtensionRaw]
  }
- data ClientHooks = ClientHooks {
  - onCertificateRequest :: OnCertificateRequest
  - onServerCertificate :: OnServerCertificate
  - onSuggestALPN :: IO (Maybe [ByteString])
  - onCustomFFDHEGroup :: DHParams -> DHPublic -> IO GroupUsage
  }
- type OnCertificateRequest = ([CertificateType], Maybe [HashAndSignatureAlgorithm], [DistinguishedName]) -> IO (Maybe (CertificateChain, PrivKey))
- type OnServerCertificate = CertificateStore -> ValidationCache -> ServiceID -> CertificateChain -> IO [FailedReason]
- data ServerHooks = ServerHooks {
  - onClientCertificate :: CertificateChain -> IO CertificateUsage
  - onUnverifiedClientCert :: IO Bool
  - onCipherChoosing :: Version -> [Cipher] -> Cipher
  - onServerNameIndication :: Maybe HostName -> IO Credentials
  - onNewHandshake :: Measurement -> IO Bool
  - onALPNClientSuggest :: Maybe ([ByteString] -> IO ByteString)
  - onEncryptedExtensionsCreating :: [ExtensionRaw] -> IO [ExtensionRaw]
  }
- data Measurement = Measurement {
  - nbHandshakes :: !Word32
  - bytesReceived :: !Word32
  - bytesSent :: !Word32
  }
- data Supported = Supported {
  - supportedVersions :: [Version]
  - supportedCiphers :: [Cipher]
  - supportedCompressions :: [Compression]
  - supportedHashSignatures :: [HashAndSignatureAlgorithm]
  - supportedSecureRenegotiation :: Bool
  - supportedClientInitiatedRenegotiation :: Bool
  - supportedExtendedMasterSec :: EMSMode
  - supportedSession :: Bool
  - supportedFallbackScsv :: Bool
  - supportedEmptyPacket :: Bool
  - supportedGroups :: [Group]
  }
- data DebugParams = DebugParams {
  - debugSeed :: Maybe Seed
  - debugPrintSeed :: Seed -> IO ()
  - debugVersionForced :: Maybe Version
  - debugKeyLogger :: String -> IO ()
  }
- newtype Credentials = Credentials [Credential]
- type Credential = (CertificateChain, PrivKey)
- credentialLoadX509 :: FilePath -> FilePath -> IO (Either String Credential)
- credentialLoadX509FromMemory :: ByteString -> ByteString -> Either String Credential
- credentialLoadX509Chain :: FilePath -> [FilePath] -> FilePath -> IO (Either String Credential)
- credentialLoadX509ChainFromMemory :: ByteString -> [ByteString] -> ByteString -> Either String Credential
- data SessionManager = SessionManager {
  - sessionResume :: SessionID -> IO (Maybe SessionData)
  - sessionResumeOnlyOnce :: SessionID -> IO (Maybe SessionData)
  - sessionEstablish :: SessionID -> SessionData -> IO ()
  - sessionInvalidate :: SessionID -> IO ()
  }
- noSessionManager :: SessionManager
- type SessionID = ByteString
- data SessionData = SessionData {
  - sessionVersion :: Version
  - sessionCipher :: CipherID
  - sessionCompression :: CompressionID
  - sessionClientSNI :: Maybe HostName
  - sessionSecret :: ByteString
  - sessionGroup :: Maybe Group
  - sessionTicketInfo :: Maybe TLS13TicketInfo
  - sessionALPN :: Maybe ByteString
  - sessionMaxEarlyDataSize :: Int
  - sessionFlags :: [SessionFlag]
  }
- data SessionFlag = SessionEMS
- data TLS13TicketInfo
- data ValidationCache = ValidationCache {
  - cacheQuery :: ValidationCacheQueryCallback
  - cacheAdd :: ValidationCacheAddCallback
  }
- type ValidationCacheQueryCallback = ServiceID -> Fingerprint -> Certificate -> IO ValidationCacheResult
- type ValidationCacheAddCallback = ServiceID -> Fingerprint -> Certificate -> IO ()
- data ValidationCacheResult
  - = ValidationCachePass
  - | ValidationCacheDenied String
  - | ValidationCacheUnknown
- exceptionValidationCache :: [(ServiceID, Fingerprint)] -> ValidationCache
- data Version
  - = SSL2
  - | SSL3
  - | TLS10
  - | TLS11
  - | TLS12
  - | TLS13
- data Compression = forall a.CompressionC a => Compression a
- nullCompression :: Compression
- type HashAndSignatureAlgorithm = (HashAlgorithm, SignatureAlgorithm)
- data HashAlgorithm
  - = HashNone
  - | HashMD5
  - | HashSHA1
  - | HashSHA224
  - | HashSHA256
  - | HashSHA384
  - | HashSHA512
  - | HashIntrinsic
  - | HashOther Word8
- data SignatureAlgorithm
  - = SignatureAnonymous
  - | SignatureRSA
  - | SignatureDSS
  - | SignatureECDSA
  - | SignatureRSApssRSAeSHA256
  - | SignatureRSApssRSAeSHA384
  - | SignatureRSApssRSAeSHA512
  - | SignatureEd25519
  - | SignatureEd448
  - | SignatureRSApsspssSHA256
  - | SignatureRSApsspssSHA384
  - | SignatureRSApsspssSHA512
  - | SignatureOther Word8
- data Group
  - = P256
  - | P384
  - | P521
  - | X25519
  - | X448
  - | FFDHE2048
  - | FFDHE3072
  - | FFDHE4096
  - | FFDHE6144
  - | FFDHE8192
- data EMSMode
  - = NoEMS
  - | AllowEMS
  - | RequireEMS
- type DHParams = Params
- type DHPublic = PublicNumber
- data GroupUsage
  - = GroupUsageValid
  - | GroupUsageInsecure
  - | GroupUsageUnsupported String
  - | GroupUsageInvalidPublic
- data CertificateUsage
  - = CertificateUsageAccept
  - | CertificateUsageReject CertificateRejectReason
- data CertificateRejectReason
  - = CertificateRejectExpired
  - | CertificateRejectRevoked
  - | CertificateRejectUnknownCA
  - | CertificateRejectAbsent
  - | CertificateRejectOther String
- data CertificateType
  - = CertificateType_RSA_Sign
  - | CertificateType_DSS_Sign
  - | CertificateType_ECDSA_Sign
  - | CertificateType_Ed25519_Sign
  - | CertificateType_Ed448_Sign
  - | CertificateType_RSA_Fixed_DH
  - | CertificateType_DSS_Fixed_DH
  - | CertificateType_RSA_Ephemeral_DH
  - | CertificateType_DSS_Ephemeral_DH
  - | CertificateType_fortezza_dms
  - | CertificateType_RSA_Fixed_ECDH
  - | CertificateType_ECDSA_Fixed_ECDH
  - | CertificateType_Unknown Word8
- type HostName = String
- data MaxFragmentEnum
  - = MaxFragment512
  - | MaxFragment1024
  - | MaxFragment2048
  - | MaxFragment4096
- ctxConnection :: Context -> Backend
- contextFlush :: Context -> IO ()
- contextClose :: Context -> IO ()
- data Information = Information {
  - infoVersion :: Version
  - infoCipher :: Cipher
  - infoCompression :: Compression
  - infoMasterSecret :: Maybe ByteString
  - infoExtendedMasterSec :: Bool
  - infoClientRandom :: Maybe ClientRandom
  - infoServerRandom :: Maybe ServerRandom
  - infoNegotiatedGroup :: Maybe Group
  - infoTLS13HandshakeMode :: Maybe HandshakeMode13
  - infoIsEarlyDataAccepted :: Bool
  }
- contextGetInformation :: Context -> IO (Maybe Information)
- data ClientRandom
- data ServerRandom
- unClientRandom :: ClientRandom -> ByteString
- unServerRandom :: ServerRandom -> ByteString
- data HandshakeMode13
  - = FullHandshake
  - | HelloRetryRequest
  - | PreSharedKey
  - | RTT0
- getClientCertificateChain :: Context -> IO (Maybe CertificateChain)
- getNegotiatedProtocol :: MonadIO m => Context -> m (Maybe ByteString)
- getClientSNI :: MonadIO m => Context -> m (Maybe HostName)
- updateKey :: MonadIO m => Context -> KeyUpdateRequest -> m Bool
- data KeyUpdateRequest
  - = OneWay
  - | TwoWay
- requestCertificate :: MonadIO m => Context -> m Bool
- data Hooks = Hooks {
  - hookRecvHandshake :: Handshake -> IO Handshake
  - hookRecvHandshake13 :: Handshake13 -> IO Handshake13
  - hookRecvCertificates :: CertificateChain -> IO ()
  - hookLogging :: Logging
  }
- contextModifyHooks :: Context -> (Hooks -> Hooks) -> IO ()
- data Handshake
- contextHookSetHandshakeRecv :: Context -> (Handshake -> IO Handshake) -> IO ()
- data Handshake13
- contextHookSetHandshake13Recv :: Context -> (Handshake13 -> IO Handshake13) -> IO ()
- contextHookSetCertificateRecv :: Context -> (CertificateChain -> IO ()) -> IO ()
- data Logging = Logging {
  - loggingPacketSent :: String -> IO ()
  - loggingPacketRecv :: String -> IO ()
  - loggingIOSent :: ByteString -> IO ()
  - loggingIORecv :: Header -> ByteString -> IO ()
  }
- data Header = Header ProtocolType Version Word16
- data ProtocolType
  - = ProtocolType_ChangeCipherSpec
  - | ProtocolType_Alert
  - | ProtocolType_Handshake
  - | ProtocolType_AppData
  - | ProtocolType_DeprecatedHandshake
- contextHookSetLogging :: Context -> Logging -> IO ()
- data TLSError
  - = Error_Misc String
  - | Error_Protocol (String, Bool, AlertDescription)
  - | Error_Certificate String
  - | Error_HandshakePolicy String
  - | Error_EOF
  - | Error_Packet String
  - | Error_Packet_unexpected String String
  - | Error_Packet_Parsing String
- data KxError
  - = RSAError Error
  - | KxUnsupported
- data AlertDescription
  - = CloseNotify
  - | UnexpectedMessage
  - | BadRecordMac
  - | DecryptionFailed
  - | RecordOverflow
  - | DecompressionFailure
  - | HandshakeFailure
  - | BadCertificate
  - | UnsupportedCertificate
  - | CertificateRevoked
  - | CertificateExpired
  - | CertificateUnknown
  - | IllegalParameter
  - | UnknownCa
  - | AccessDenied
  - | DecodeError
  - | DecryptError
  - | ExportRestriction
  - | ProtocolVersion
  - | InsufficientSecurity
  - | InternalError
  - | InappropriateFallback
  - | UserCanceled
  - | NoRenegotiation
  - | MissingExtension
  - | UnsupportedExtension
  - | CertificateUnobtainable
  - | UnrecognizedName
  - | BadCertificateStatusResponse
  - | BadCertificateHashValue
  - | UnknownPskIdentity
  - | CertificateRequired
  - | NoApplicationProtocol
- data TLSException
  - = Terminated Bool String TLSError
  - | HandshakeFailed TLSError
  - | ConnectionNotEstablished
- class CompressionC a where
  - compressionCID :: a -> CompressionID
  - compressionCDeflate :: a -> ByteString -> (a, ByteString)
  - compressionCInflate :: a -> ByteString -> (a, ByteString)
- type CompressionID = Word8
- data PubKey
  - = PubKeyRSA PublicKey
  - | PubKeyDSA PublicKey
  - | PubKeyDH (Integer, Integer, Integer, Maybe Integer, ([Word8], Integer))
  - | PubKeyEC PubKeyEC
  - | PubKeyX25519 PublicKey
  - | PubKeyX448 PublicKey
  - | PubKeyEd25519 PublicKey
  - | PubKeyEd448 PublicKey
  - | PubKeyUnknown OID ByteString
- data PrivKey
  - = PrivKeyRSA PrivateKey
  - | PrivKeyDSA PrivateKey
  - | PrivKeyEC PrivKeyEC
  - | PrivKeyX25519 SecretKey
  - | PrivKeyX448 SecretKey
  - | PrivKeyEd25519 SecretKey
  - | PrivKeyEd448 SecretKey
- data CipherKeyExchangeType
  - = CipherKeyExchange_RSA
  - | CipherKeyExchange_DH_Anon
  - | CipherKeyExchange_DHE_RSA
  - | CipherKeyExchange_ECDHE_RSA
  - | CipherKeyExchange_DHE_DSS
  - | CipherKeyExchange_DH_DSS
  - | CipherKeyExchange_DH_RSA
  - | CipherKeyExchange_ECDH_ECDSA
  - | CipherKeyExchange_ECDH_RSA
  - | CipherKeyExchange_ECDHE_ECDSA
  - | CipherKeyExchange_TLS13
- data Bulk = Bulk {
  - bulkName :: String
  - bulkKeySize :: Int
  - bulkIVSize :: Int
  - bulkExplicitIV :: Int
  - bulkAuthTagLen :: Int
  - bulkBlockSize :: Int
  - bulkF :: BulkFunctions
  }
- data BulkFunctions
  - = BulkBlockF (BulkDirection -> BulkKey -> BulkBlock)
  - | BulkStreamF (BulkDirection -> BulkKey -> BulkStream)
  - | BulkAeadF (BulkDirection -> BulkKey -> BulkAEAD)
- data BulkDirection
  - = BulkEncrypt
  - | BulkDecrypt
- data BulkState
  - = BulkStateStream BulkStream
  - | BulkStateBlock BulkBlock
  - | BulkStateAEAD BulkAEAD
  - | BulkStateUninitialized
- newtype BulkStream = BulkStream (ByteString -> (ByteString, BulkStream))
- type BulkBlock = BulkIV -> ByteString -> (ByteString, BulkIV)
- type BulkAEAD = BulkNonce -> ByteString -> BulkAdditionalData -> (ByteString, AuthTag)
- bulkInit :: Bulk -> BulkDirection -> BulkKey -> BulkState
- data Hash
  - = MD5
  - | SHA1
  - | SHA224
  - | SHA256
  - | SHA384
  - | SHA512
  - | SHA1_MD5
- data Cipher = Cipher {
  - cipherID :: CipherID
  - cipherName :: String
  - cipherHash :: Hash
  - cipherBulk :: Bulk
  - cipherKeyExchange :: CipherKeyExchangeType
  - cipherMinVer :: Maybe Version
  - cipherPRFHash :: Maybe Hash
  }
- type CipherID = Word16
- cipherKeyBlockSize :: Cipher -> Int
- type BulkKey = ByteString
- type BulkIV = ByteString
- type BulkNonce = ByteString
- type BulkAdditionalData = ByteString
- cipherAllowedForVersion :: Version -> Cipher -> Bool
- hasMAC :: BulkFunctions -> Bool
- hasRecordIV :: BulkFunctions -> Bool
- recvData' :: MonadIO m => Context -> m ByteString
- contextNewOnHandle :: (MonadIO m, TLSParams params) => Handle -> params -> m Context
- contextNewOnSocket :: (MonadIO m, TLSParams params) => Socket -> params -> m Context
- type Bytes = ByteString
- data ValidationChecks = ValidationChecks {
  - checkTimeValidity :: Bool
  - checkAtTime :: Maybe DateTime
  - checkStrictOrdering :: Bool
  - checkCAConstraints :: Bool
  - checkExhaustive :: Bool
  - checkLeafV3 :: Bool
  - checkLeafKeyUsage :: [ExtKeyUsageFlag]
  - checkLeafKeyPurpose :: [ExtKeyUsagePurpose]
  - checkFQHN :: Bool
  }
- data ValidationHooks = ValidationHooks {
  - hookMatchSubjectIssuer :: DistinguishedName -> Certificate -> Bool
  - hookValidateTime :: DateTime -> Certificate -> [FailedReason]
  - hookValidateName :: HostName -> Certificate -> [FailedReason]
  - hookFilterReason :: [FailedReason] -> [FailedReason]
  }

# Basic APIs

data Context #

A TLS Context keep tls specific state, parameters and backend information.

contextNew #

Arguments

:: (MonadIO m, HasBackend backend, TLSParams params) |
=> backend | Backend abstraction with specific method to interact with the connection type.
-> params | Parameters of the context.
-> m Context |

create a new context using the backend and parameters specified.

handshake :: MonadIO m => Context -> m () #

Handshake for a new TLS connection This is to be called at the beginning of a connection, and during renegotiation

sendData :: MonadIO m => Context -> ByteString -> m () #

sendData sends a bunch of data. It will automatically chunk data to acceptable packet size

recvData :: MonadIO m => Context -> m ByteString #

Get data out of Data packet, and automatically renegotiate if a Handshake ClientHello is received. An empty result means EOF.

bye :: MonadIO m => Context -> m () #

notify the context that this side wants to close connection. this is important that it is called before closing the handle, otherwise the session might not be resumable (for version < TLS1.2).

this doesn't actually close the handle

# Backend abstraction

class HasBackend a where #

Methods

initializeBackend :: a -> IO () #

getBackend :: a -> Backend #

#### Instances

Instances details

HasBackend Handle # |
Instance details Defined in Network.TLS.Backend Methods initializeBackend :: Handle -> IO () # getBackend :: Handle -> Backend #
HasBackend Socket # |
Instance details Defined in Network.TLS.Backend Methods initializeBackend :: Socket -> IO () # getBackend :: Socket -> Backend #
HasBackend Backend # |
Instance details Defined in Network.TLS.Backend Methods initializeBackend :: Backend -> IO () # getBackend :: Backend -> Backend #

data Backend #

Connection IO backend

Constructors

Backend |
Fields backendFlush :: IO () Flush the connection sending buffer, if any. backendClose :: IO () Close the connection. backendSend :: ByteString -> IO () Send a bytestring through the connection. backendRecv :: Int -> IO ByteString Receive specified number of bytes from the connection.

#### Instances

Instances details

HasBackend Backend # |
Instance details Defined in Network.TLS.Backend Methods initializeBackend :: Backend -> IO () # getBackend :: Backend -> Backend #

# Parameters

class TLSParams a #

Minimal complete definition

getTLSCommonParams, getTLSRole, doHandshake, doHandshakeWith, doRequestCertificate, doPostHandshakeAuthWith

#### Instances

Instances details

TLSParams ServerParams # |
Instance details Defined in Network.TLS.Context Methods getTLSCommonParams :: ServerParams -> CommonParams getTLSRole :: ServerParams -> Role doHandshake :: ServerParams -> Context -> IO () doHandshakeWith :: ServerParams -> Context -> Handshake -> IO () doRequestCertificate :: ServerParams -> Context -> IO Bool doPostHandshakeAuthWith :: ServerParams -> Context -> Handshake13 -> IO ()
TLSParams ClientParams # |
Instance details Defined in Network.TLS.Context Methods getTLSCommonParams :: ClientParams -> CommonParams getTLSRole :: ClientParams -> Role doHandshake :: ClientParams -> Context -> IO () doHandshakeWith :: ClientParams -> Context -> Handshake -> IO () doRequestCertificate :: ClientParams -> Context -> IO Bool doPostHandshakeAuthWith :: ClientParams -> Context -> Handshake13 -> IO ()

data ClientParams #

Constructors

ClientParams |
Fields clientUseMaxFragmentLength :: Maybe MaxFragmentEnum Default: `Nothing` clientServerIdentification :: (HostName, ByteString) Define the name of the server, along with an extra service identification blob. this is important that the hostname part is properly filled for security reason, as it allow to properly associate the remote side with the given certificate during a handshake. The extra blob is useful to differentiate services running on the same host, but that might have different certificates given. It's only used as part of the X509 validation infrastructure. This value is typically set by `defaultParamsClient`. clientUseServerNameIndication :: Bool Allow the use of the Server Name Indication TLS extension during handshake, which allow the client to specify which host name, it's trying to access. This is useful to distinguish CNAME aliasing (e.g. web virtual host). Default: `True` clientWantSessionResume :: Maybe (SessionID, SessionData) try to establish a connection using this session. Default: `Nothing` clientShared :: Shared See the default value of `Shared`. clientHooks :: ClientHooks See the default value of `ClientHooks`. clientSupported :: Supported In this element, you'll need to override the default empty value of of `supportedCiphers` with a suitable cipherlist. See the default value of `Supported`. clientDebug :: DebugParams See the default value of `DebugParams`. clientEarlyData :: Maybe ByteString Client tries to send this early data in TLS 1.3 if possible. If not accepted by the server, it is application's responsibility to re-sent it. Default: `Nothing`

#### Instances

Instances details

Show ClientParams # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> ClientParams -> ShowS # show :: ClientParams -> String # showList :: [ClientParams] -> ShowS #
TLSParams ClientParams # |
Instance details Defined in Network.TLS.Context Methods getTLSCommonParams :: ClientParams -> CommonParams getTLSRole :: ClientParams -> Role doHandshake :: ClientParams -> Context -> IO () doHandshakeWith :: ClientParams -> Context -> Handshake -> IO () doRequestCertificate :: ClientParams -> Context -> IO Bool doPostHandshakeAuthWith :: ClientParams -> Context -> Handshake13 -> IO ()

defaultParamsClient :: HostName -> ByteString -> ClientParams #

data ServerParams #

Constructors

ServerParams |
Fields serverWantClientCert :: Bool Request a certificate from client. Default: `False` serverCACertificates :: [SignedCertificate] This is a list of certificates from which the disinguished names are sent in certificate request messages. For TLS1.0, it should not be empty. Default: '[]' serverDHEParams :: Maybe DHParams Server Optional Diffie Hellman parameters. Setting parameters is necessary for FFDHE key exchange when clients are not compatible with RFC 7919. Value can be one of the standardized groups from module Network.TLS.Extra.FFDHE or custom parameters generated with `generateParams`. Default: `Nothing` serverHooks :: ServerHooks See the default value of `ServerHooks`. serverShared :: Shared See the default value of `Shared`. serverSupported :: Supported See the default value of `Supported`. serverDebug :: DebugParams See the default value of `DebugParams`. serverEarlyDataSize :: Int Server accepts this size of early data in TLS 1.3. 0 (or lower) means that the server does not accept early data. Default: 0 serverTicketLifetime :: Int Lifetime in seconds for session tickets generated by the server. Acceptable value range is 0 to 604800 (7 days). The default lifetime is 86400 seconds (1 day). Default: 86400 (one day)

#### Instances

Instances details

Show ServerParams # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> ServerParams -> ShowS # show :: ServerParams -> String # showList :: [ServerParams] -> ShowS #
Default ServerParams # |
Instance details Defined in Network.TLS.Parameters Methods def :: ServerParams #
TLSParams ServerParams # |
Instance details Defined in Network.TLS.Context Methods getTLSCommonParams :: ServerParams -> CommonParams getTLSRole :: ServerParams -> Role doHandshake :: ServerParams -> Context -> IO () doHandshakeWith :: ServerParams -> Context -> Handshake -> IO () doRequestCertificate :: ServerParams -> Context -> IO Bool doPostHandshakeAuthWith :: ServerParams -> Context -> Handshake13 -> IO ()

## Shared

data Shared #

Parameters that are common to clients and servers.

Constructors

Shared |
Fields sharedCredentials :: Credentials The list of certificates and private keys that a server will use as part of authentication to clients. Actual credentials that are used are selected dynamically from this list based on client capabilities. Additional credentials returned by `onServerNameIndication` are also considered. When credential list is left empty (the default value), no key exchange can take place. Default: `mempty` sharedSessionManager :: SessionManager Callbacks used by clients and servers in order to resume TLS sessions. The default implementation never resumes sessions. Package tls-session-manager provides an in-memory implementation. Default: `noSessionManager` sharedCAStore :: CertificateStore A collection of trust anchors to be used by a client as part of validation of server certificates. This is set as first argument to function `onServerCertificate`. Package x509-system gives access to a default certificate store configured in the system. Default: `mempty` sharedValidationCache :: ValidationCache Callbacks that may be used by a client to cache certificate validation results (positive or negative) and avoid expensive signature check. The default implementation does not have any caching. See the default value of `ValidationCache`. sharedHelloExtensions :: [ExtensionRaw] Additional extensions to be sent during the Hello sequence. For a client this is always included in message ClientHello. For a server, this is sent in messages ServerHello or EncryptedExtensions based on the TLS version. Default: `[]`

#### Instances

Instances details

Show Shared # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> Shared -> ShowS # show :: Shared -> String # showList :: [Shared] -> ShowS #
Default Shared # |
Instance details Defined in Network.TLS.Parameters Methods def :: Shared #

## Hooks

data ClientHooks #

A set of callbacks run by the clients for various corners of TLS establishment

Constructors

ClientHooks |
Fields onCertificateRequest :: OnCertificateRequest This action is called when the a certificate request is received from the server. The callback argument is the information from the request. The server, at its discretion, may be willing to continue the handshake without a client certificate. Therefore, the callback is free to return `Nothing` to indicate that no client certificate should be sent, despite the server's request. In some cases it may be appropriate to get user consent before sending the certificate; the content of the user's certificate may be sensitive and intended only for specific servers. The action should select a certificate chain of one of the given certificate types and one of the certificates in the chain should (if possible) be signed by one of the given distinguished names. Some servers, that don't have a narrow set of preferred issuer CAs, will send an empty `DistinguishedName` list, rather than send all the names from their trusted CA bundle. If the client does not have a certificate chaining to a matching CA, it may choose a default certificate instead. Each certificate except the last should be signed by the following one. The returned private key must be for the first certificates in the chain. This key will be used to signing the certificate verify message. The public key in the first certificate, and the matching returned private key must be compatible with one of the list of `HashAndSignatureAlgorithm` value when provided. TLS 1.3 changes the meaning of the list elements, adding explicit code points for each supported pair of hash and signature (public key) algorithms, rather than combining separate codes for the hash and key. For details see RFC 8446 section 4.2.3. When no compatible certificate chain is available, return `Nothing` if it is OK to continue without a client certificate. Returning a non-matching certificate should result in a handshake failure. While the TLS version is not provided to the callback, the content of the `signature_algorithms` list provides a strong hint, since TLS 1.3 servers will generally list RSA pairs with a hash component of `Intrinsic` (`0x08`). Note that is is the responsibility of this action to select a certificate matching one of the requested certificate types (public key algorithms). Returning a non-matching one will lead to handshake failure later. Default: returns `Nothing` anyway. onServerCertificate :: OnServerCertificate Used by the client to validate the server certificate. The default implementation calls `validateDefault` which validates according to the default hooks and checks provided by Data.X509.Validation. This can be replaced with a custom validation function using different settings. The function is not expected to verify the key-usage extension of the end-entity certificate, as this depends on the dynamically-selected cipher and this part should not be cached. Key-usage verification is performed by the library internally. Default: `validateDefault` onSuggestALPN :: IO (Maybe [ByteString]) This action is called when the client sends ClientHello to determine ALPN values such as '["h2", "http/1.1"]'. Default: returns `Nothing` onCustomFFDHEGroup :: DHParams -> DHPublic -> IO GroupUsage This action is called to validate DHE parameters when the server selected a finite-field group not part of the "Supported Groups Registry" or not part of `supportedGroups` list. With TLS 1.3 custom groups have been removed from the protocol, so this callback is only used when the version negotiated is 1.2 or below. The default behavior with (dh_p, dh_g, dh_size) and pub as follows: rejecting if dh_p is even rejecting unless 1 < dh_g && dh_g < dh_p - 1 rejecting unless 1 < dh_p && pub < dh_p - 1 rejecting if dh_size < 1024 (to prevent Logjam attack) See RFC 7919 section 3.1 for recommandations.

#### Instances

Instances details

Show ClientHooks # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> ClientHooks -> ShowS # show :: ClientHooks -> String # showList :: [ClientHooks] -> ShowS #
Default ClientHooks # |
Instance details Defined in Network.TLS.Parameters Methods def :: ClientHooks #

type OnCertificateRequest = ([CertificateType], Maybe [HashAndSignatureAlgorithm], [DistinguishedName]) -> IO (Maybe (CertificateChain, PrivKey)) #

Type for `onCertificateRequest`. This type synonym is to make document readable.

type OnServerCertificate = CertificateStore -> ValidationCache -> ServiceID -> CertificateChain -> IO [FailedReason] #

Type for `onServerCertificate`. This type synonym is to make document readable.

data ServerHooks #

A set of callbacks run by the server for various corners of the TLS establishment

Constructors

ServerHooks |
- Fields onClientCertificate :: CertificateChain -> IO CertificateUsage This action is called when a client certificate chain is received from the client. When it returns a CertificateUsageReject value, the handshake is aborted. The function is not expected to verify the key-usage extension of the certificate. This verification is performed by the library internally. Default: returns the followings:
      CertificateUsageReject (CertificateRejectOther "no client certificates expected")
onUnverifiedClientCert :: IO Bool This action is called when the client certificate cannot be verified. Return `True` to accept the certificate anyway, or `False` to fail verification. Default: returns `False` onCipherChoosing :: Version -> [Cipher] -> Cipher Allow the server to choose the cipher relative to the the client version and the client list of ciphers. This could be useful with old clients and as a workaround to the BEAST (where RC4 is sometimes prefered with TLS < 1.1) The client cipher list cannot be empty. Default: taking the head of ciphers. onServerNameIndication :: Maybe HostName -> IO Credentials Allow the server to indicate additional credentials to be used depending on the host name indicated by the client. This is most useful for transparent proxies where credentials must be generated on the fly according to the host the client is trying to connect to. Returned credentials may be ignored if a client does not support the signature algorithms used in the certificate chain. Default: returns `mempty` onNewHandshake :: Measurement -> IO Bool At each new handshake, we call this hook to see if we allow handshake to happens. Default: returns `True` onALPNClientSuggest :: Maybe ([ByteString] -> IO ByteString) Allow the server to choose an application layer protocol suggested from the client through the ALPN (Application Layer Protocol Negotiation) extensions. If the server supports no protocols that the client advertises an empty `ByteString` should be returned. Default: `Nothing` onEncryptedExtensionsCreating :: [ExtensionRaw] -> IO [ExtensionRaw] Allow to modify extensions to be sent in EncryptedExtensions of TLS 1.3. Default: 'return . id'

#### Instances

Instances details

Show ServerHooks # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> ServerHooks -> ShowS # show :: ServerHooks -> String # showList :: [ServerHooks] -> ShowS #
Default ServerHooks # |
Instance details Defined in Network.TLS.Parameters Methods def :: ServerHooks #

data Measurement #

record some data about this connection.

Constructors

Measurement |
Fields nbHandshakes :: !Word32 number of handshakes on this context bytesReceived :: !Word32 bytes received since last handshake bytesSent :: !Word32 bytes sent since last handshake

#### Instances

Instances details

Eq Measurement # |
Instance details Defined in Network.TLS.Measurement Methods (==) :: Measurement -> Measurement -> Bool # (/=) :: Measurement -> Measurement -> Bool #
Show Measurement # |
Instance details Defined in Network.TLS.Measurement Methods showsPrec :: Int -> Measurement -> ShowS # show :: Measurement -> String # showList :: [Measurement] -> ShowS #

## Supported

data Supported #

List all the supported algorithms, versions, ciphers, etc supported.

Constructors

Supported |
- Fields supportedVersions :: [Version] Supported versions by this context. On the client side, the highest version will be used to establish the connection. On the server side, the highest version that is less or equal than the client version will be chosen. Versions should be listed in preference order, i.e. higher versions first. Default: `[TLS13,TLS12,TLS11,TLS10]` supportedCiphers :: [Cipher] Supported cipher methods. The default is empty, specify a suitable cipher list. `ciphersuite_default` is often a good choice. Default: `[]` supportedCompressions :: [Compression] Supported compressions methods. By default only the "null" compression is supported, which means no compression will be performed. Allowing other compression method is not advised as it causes a connection failure when TLS 1.3 is negotiated. Default: `[nullCompression]` supportedHashSignatures :: [HashAndSignatureAlgorithm] All supported hash/signature algorithms pair for client certificate verification and server signature in (EC)DHE, ordered by decreasing priority. This list is sent to the peer as part of the "signature_algorithms" extension. It is used to restrict accepted signatures received from the peer at TLS level (not in X.509 certificates), but only when the TLS version is 1.2 or above. In order to disable SHA-1 one must then also disable earlier protocol versions in `supportedVersions`. The list also impacts the selection of possible algorithms when generating signatures. Note: with TLS 1.3 some algorithms have been deprecated and will not be used even when listed in the parameter: MD5, SHA-1, SHA-224, RSA PKCS#1, DSS. Default:
        [ (HashIntrinsic,     SignatureEd448)
        , (HashIntrinsic,     SignatureEd25519)
        , (Struct.HashSHA256, SignatureECDSA)
        , (Struct.HashSHA384, SignatureECDSA)
        , (Struct.HashSHA512, SignatureECDSA)
        , (HashIntrinsic,     SignatureRSApssRSAeSHA512)
        , (HashIntrinsic,     SignatureRSApssRSAeSHA384)
        , (HashIntrinsic,     SignatureRSApssRSAeSHA256)
        , (Struct.HashSHA512, SignatureRSA)
        , (Struct.HashSHA384, SignatureRSA)
        , (Struct.HashSHA256, SignatureRSA)
        , (Struct.HashSHA1,   SignatureRSA)
        , (Struct.HashSHA1,   SignatureDSS)
        ]
supportedSecureRenegotiation :: Bool Secure renegotiation defined in RFC5746. If `True`, clients send the renegotiation_info extension. If `True`, servers handle the extension or the renegotiation SCSV then send the renegotiation_info extension. Default: `True` supportedClientInitiatedRenegotiation :: Bool If `True`, renegotiation is allowed from the client side. This is vulnerable to DOS attacks. If `False`, renegotiation is allowed only from the server side via HelloRequest. Default: `False` supportedExtendedMasterSec :: EMSMode The mode regarding extended master secret. Enabling this extension provides better security for TLS versions 1.0 to 1.2. TLS 1.3 provides the security properties natively and does not need the extension. By default the extension is enabled but not required. If mode is set to `RequireEMS`, the handshake will fail when the peer does not support the extension. It is also advised to disable SSLv3 which does not have this mechanism. Default: `AllowEMS` supportedSession :: Bool Set if we support session. Default: `True` supportedFallbackScsv :: Bool Support for fallback SCSV defined in RFC7507. If `True`, servers reject handshakes which suggest a lower protocol than the highest protocol supported. Default: `True` supportedEmptyPacket :: Bool In ver <= TLS1.0, block ciphers using CBC are using CBC residue as IV, which can be guessed by an attacker. Hence, an empty packet is normally sent before a normal data packet, to prevent guessability. Some Microsoft TLS-based protocol implementations, however, consider these empty packets as a protocol violation and disconnect. If this parameter is `False`, empty packets will never be added, which is less secure, but might help in rare cases. Default: `True` supportedGroups :: [Group] A list of supported elliptic curves and finite-field groups in the preferred order. The list is sent to the server as part of the "supported_groups" extension. It is used in both clients and servers to restrict accepted groups in DH key exchange. Up until TLS v1.2, it is also used by a client to restrict accepted elliptic curves in ECDSA signatures. The default value includes all groups with security strength of 128 bits or more. Default: `[X25519,X448,P256,FFDHE3072,FFDHE4096,P384,FFDHE6144,FFDHE8192,P521]`

#### Instances

Instances details

Eq Supported # |
Instance details Defined in Network.TLS.Parameters Methods (==) :: Supported -> Supported -> Bool # (/=) :: Supported -> Supported -> Bool #
Show Supported # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> Supported -> ShowS # show :: Supported -> String # showList :: [Supported] -> ShowS #
Default Supported # |
Instance details Defined in Network.TLS.Parameters Methods def :: Supported #

## Debug parameters

data DebugParams #

All settings should not be used in production

Constructors

DebugParams |
Fields debugSeed :: Maybe Seed Disable the true randomness in favor of deterministic seed that will produce a deterministic random from. This is useful for tests and debugging purpose. Do not use in production Default: `Nothing` debugPrintSeed :: Seed -> IO () Add a way to print the seed that was randomly generated. re-using the same seed will reproduce the same randomness with `debugSeed` Default: no printing debugVersionForced :: Maybe Version Force to choose this version in the server side. Default: `Nothing` debugKeyLogger :: String -> IO () Printing master keys. Default: no printing

#### Instances

Instances details

Show DebugParams # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> DebugParams -> ShowS # show :: DebugParams -> String # showList :: [DebugParams] -> ShowS #
Default DebugParams # |
Instance details Defined in Network.TLS.Parameters Methods def :: DebugParams #

# Shared parameters

## Credentials

newtype Credentials #

Constructors

Credentials [Credential] |

#### Instances

Instances details

Semigroup Credentials # |
Instance details Defined in Network.TLS.Credentials Methods (<>) :: Credentials -> Credentials -> Credentials # sconcat :: NonEmpty Credentials -> Credentials # stimes :: Integral b => b -> Credentials -> Credentials #
Monoid Credentials # |
Instance details Defined in Network.TLS.Credentials Methods mempty :: Credentials # mappend :: Credentials -> Credentials -> Credentials # mconcat :: [Credentials] -> Credentials #

type Credential = (CertificateChain, PrivKey) #

credentialLoadX509 #

Arguments

:: FilePath | public certificate (X.509 format)
-> FilePath | private key associated
-> IO (Either String Credential) |

try to create a new credential object from a public certificate and the associated private key that are stored on the filesystem in PEM format.

credentialLoadX509FromMemory :: ByteString -> ByteString -> Either String Credential #

similar to `credentialLoadX509` but take the certificate and private key from memory instead of from the filesystem.

credentialLoadX509Chain #

Arguments

:: FilePath | public certificate (X.509 format)
-> [FilePath] | chain certificates (X.509 format)
-> FilePath | private key associated
-> IO (Either String Credential) |

similar to `credentialLoadX509` but also allow specifying chain certificates.

credentialLoadX509ChainFromMemory :: ByteString -> [ByteString] -> ByteString -> Either String Credential #

similar to `credentialLoadX509FromMemory` but also allow specifying chain certificates.

## Session manager

data SessionManager #

A session manager

Constructors

SessionManager |
Fields sessionResume :: SessionID -> IO (Maybe SessionData) used on server side to decide whether to resume a client session. sessionResumeOnlyOnce :: SessionID -> IO (Maybe SessionData) used on server side to decide whether to resume a client session for TLS 1.3 0RTT. For a given `SessionID`, the implementation must return its `SessionData` only once and must not return the same `SessionData` after the call. sessionEstablish :: SessionID -> SessionData -> IO () used when a session is established. sessionInvalidate :: SessionID -> IO () used when a session is invalidated.

noSessionManager :: SessionManager #

The session manager to do nothing.

type SessionID = ByteString #

A session ID

data SessionData #

Session data to resume

Constructors

SessionData |
Fields sessionVersion :: Version sessionCipher :: CipherID sessionCompression :: CompressionID sessionClientSNI :: Maybe HostName sessionSecret :: ByteString sessionGroup :: Maybe Group sessionTicketInfo :: Maybe TLS13TicketInfo sessionALPN :: Maybe ByteString sessionMaxEarlyDataSize :: Int sessionFlags :: [SessionFlag]

#### Instances

Instances details

Eq SessionData # |
Instance details Defined in Network.TLS.Types Methods (==) :: SessionData -> SessionData -> Bool # (/=) :: SessionData -> SessionData -> Bool #
Show SessionData # |
Instance details Defined in Network.TLS.Types Methods showsPrec :: Int -> SessionData -> ShowS # show :: SessionData -> String # showList :: [SessionData] -> ShowS #

data SessionFlag #

Some session flags

Constructors

SessionEMS | Session created with Extended Master Secret

#### Instances

Instances details

Enum SessionFlag # |
Instance details Defined in Network.TLS.Types Methods succ :: SessionFlag -> SessionFlag # pred :: SessionFlag -> SessionFlag # toEnum :: Int -> SessionFlag # fromEnum :: SessionFlag -> Int # enumFrom :: SessionFlag -> [SessionFlag] # enumFromThen :: SessionFlag -> SessionFlag -> [SessionFlag] # enumFromTo :: SessionFlag -> SessionFlag -> [SessionFlag] # enumFromThenTo :: SessionFlag -> SessionFlag -> SessionFlag -> [SessionFlag] #
Eq SessionFlag # |
Instance details Defined in Network.TLS.Types Methods (==) :: SessionFlag -> SessionFlag -> Bool # (/=) :: SessionFlag -> SessionFlag -> Bool #
Show SessionFlag # |
Instance details Defined in Network.TLS.Types Methods showsPrec :: Int -> SessionFlag -> ShowS # show :: SessionFlag -> String # showList :: [SessionFlag] -> ShowS #

data TLS13TicketInfo #

#### Instances

Instances details

Eq TLS13TicketInfo # |
Instance details Defined in Network.TLS.Types Methods (==) :: TLS13TicketInfo -> TLS13TicketInfo -> Bool # (/=) :: TLS13TicketInfo -> TLS13TicketInfo -> Bool #
Show TLS13TicketInfo # |
Instance details Defined in Network.TLS.Types Methods showsPrec :: Int -> TLS13TicketInfo -> ShowS # show :: TLS13TicketInfo -> String # showList :: [TLS13TicketInfo] -> ShowS #

## Validation Cache

data ValidationCache #

All the callbacks needed for querying and adding to the cache.

Constructors

ValidationCache |
Fields cacheQuery :: ValidationCacheQueryCallback cache querying callback cacheAdd :: ValidationCacheAddCallback cache adding callback

#### Instances

Instances details

Default ValidationCache |
Instance details Defined in Data.X509.Validation.Cache Methods def :: ValidationCache #

type ValidationCacheQueryCallback #

Arguments

= ServiceID | connection's identification
-> Fingerprint | fingerprint of the leaf certificate
-> Certificate | leaf certificate
-> IO ValidationCacheResult | return if the operation is succesful or not

Validation cache query callback type

type ValidationCacheAddCallback #

Arguments

= ServiceID | connection's identification
-> Fingerprint | fingerprint of the leaf certificate
-> Certificate | leaf certificate
-> IO () |

Validation cache callback type

data ValidationCacheResult #

The result of a cache query

Constructors

ValidationCachePass | cache allow this fingerprint to go through
ValidationCacheDenied String | cache denied this fingerprint for further validation
ValidationCacheUnknown | unknown fingerprint in cache

#### Instances

Instances details

Eq ValidationCacheResult |
Instance details Defined in Data.X509.Validation.Cache Methods (==) :: ValidationCacheResult -> ValidationCacheResult -> Bool # (/=) :: ValidationCacheResult -> ValidationCacheResult -> Bool #
Show ValidationCacheResult |
Instance details Defined in Data.X509.Validation.Cache Methods showsPrec :: Int -> ValidationCacheResult -> ShowS # show :: ValidationCacheResult -> String # showList :: [ValidationCacheResult] -> ShowS #

exceptionValidationCache :: [(ServiceID, Fingerprint)] -> ValidationCache #

create a simple constant cache that list exceptions to the certification validation. Typically this is use to allow self-signed certificates for specific use, with out-of-bounds user checks.

No fingerprints will be added after the instance is created.

The underlying structure for the check is kept as a list, as usually the exception list will be short, but when the list go above a dozen exceptions it's recommended to use another cache mechanism with a faster lookup mechanism (hashtable, map, etc).

Note that only one fingerprint is allowed per ServiceID, for other use, another cache mechanism need to be use.

# Types

## For `Supported`

data Version #

Versions known to TLS

SSL2 is just defined, but this version is and will not be supported.

Constructors

SSL2 |
SSL3 |
TLS10 |
TLS11 |
TLS12 |
TLS13 |

#### Instances

Instances details

Bounded Version # |
Instance details Defined in Network.TLS.Types Methods minBound :: Version # maxBound :: Version #
Eq Version # |
Instance details Defined in Network.TLS.Types Methods (==) :: Version -> Version -> Bool # (/=) :: Version -> Version -> Bool #
Ord Version # |
Instance details Defined in Network.TLS.Types Methods compare :: Version -> Version -> Ordering # (<) :: Version -> Version -> Bool # (<=) :: Version -> Version -> Bool # (>) :: Version -> Version -> Bool # (>=) :: Version -> Version -> Bool # max :: Version -> Version -> Version # min :: Version -> Version -> Version #
Show Version # |
Instance details Defined in Network.TLS.Types Methods showsPrec :: Int -> Version -> ShowS # show :: Version -> String # showList :: [Version] -> ShowS #

data Compression #

every compression need to be wrapped in this, to fit in structure

Constructors

forall a.CompressionC a => Compression a |

#### Instances

Instances details

Eq Compression # |
Instance details Defined in Network.TLS.Compression Methods (==) :: Compression -> Compression -> Bool # (/=) :: Compression -> Compression -> Bool #
Show Compression # |
Instance details Defined in Network.TLS.Compression Methods showsPrec :: Int -> Compression -> ShowS # show :: Compression -> String # showList :: [Compression] -> ShowS #

nullCompression :: Compression #

default null compression

type HashAndSignatureAlgorithm = (HashAlgorithm, SignatureAlgorithm) #

data HashAlgorithm #

Constructors

HashNone |
HashMD5 |
HashSHA1 |
HashSHA224 |
HashSHA256 |
HashSHA384 |
HashSHA512 |
HashIntrinsic |
HashOther Word8 |

#### Instances

Instances details

Eq HashAlgorithm # |
Instance details Defined in Network.TLS.Struct Methods (==) :: HashAlgorithm -> HashAlgorithm -> Bool # (/=) :: HashAlgorithm -> HashAlgorithm -> Bool #
Show HashAlgorithm # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> HashAlgorithm -> ShowS # show :: HashAlgorithm -> String # showList :: [HashAlgorithm] -> ShowS #

data SignatureAlgorithm #

Constructors

SignatureAnonymous |
SignatureRSA |
SignatureDSS |
SignatureECDSA |
SignatureRSApssRSAeSHA256 |
SignatureRSApssRSAeSHA384 |
SignatureRSApssRSAeSHA512 |
SignatureEd25519 |
SignatureEd448 |
SignatureRSApsspssSHA256 |
SignatureRSApsspssSHA384 |
SignatureRSApsspssSHA512 |
SignatureOther Word8 |

#### Instances

Instances details

Eq SignatureAlgorithm # |
Instance details Defined in Network.TLS.Struct Methods (==) :: SignatureAlgorithm -> SignatureAlgorithm -> Bool # (/=) :: SignatureAlgorithm -> SignatureAlgorithm -> Bool #
Show SignatureAlgorithm # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> SignatureAlgorithm -> ShowS # show :: SignatureAlgorithm -> String # showList :: [SignatureAlgorithm] -> ShowS #

data Group #

Constructors

P256 |
P384 |
P521 |
X25519 |
X448 |
FFDHE2048 |
FFDHE3072 |
FFDHE4096 |
FFDHE6144 |
FFDHE8192 |

#### Instances

Instances details

Eq Group # |
Instance details Defined in Network.TLS.Crypto.Types Methods (==) :: Group -> Group -> Bool # (/=) :: Group -> Group -> Bool #
Show Group # |
Instance details Defined in Network.TLS.Crypto.Types Methods showsPrec :: Int -> Group -> ShowS # show :: Group -> String # showList :: [Group] -> ShowS #

data EMSMode #

Client or server policy regarding Extended Master Secret

Constructors

NoEMS | Extended Master Secret is not used
AllowEMS | Extended Master Secret is allowed
RequireEMS | Extended Master Secret is required

#### Instances

Instances details

Eq EMSMode # |
Instance details Defined in Network.TLS.Parameters Methods (==) :: EMSMode -> EMSMode -> Bool # (/=) :: EMSMode -> EMSMode -> Bool #
Show EMSMode # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> EMSMode -> ShowS # show :: EMSMode -> String # showList :: [EMSMode] -> ShowS #

## For parameters and hooks

type DHParams = Params #

type DHPublic = PublicNumber #

data GroupUsage #

Group usage callback possible return values.

Constructors

GroupUsageValid | usage of group accepted
GroupUsageInsecure | usage of group provides insufficient security
GroupUsageUnsupported String | usage of group rejected for other reason (specified as string)
GroupUsageInvalidPublic | usage of group with an invalid public value

#### Instances

Instances details

Eq GroupUsage # |
Instance details Defined in Network.TLS.Parameters Methods (==) :: GroupUsage -> GroupUsage -> Bool # (/=) :: GroupUsage -> GroupUsage -> Bool #
Show GroupUsage # |
Instance details Defined in Network.TLS.Parameters Methods showsPrec :: Int -> GroupUsage -> ShowS # show :: GroupUsage -> String # showList :: [GroupUsage] -> ShowS #

data CertificateUsage #

Certificate Usage callback possible returns values.

Constructors

CertificateUsageAccept | usage of certificate accepted
CertificateUsageReject CertificateRejectReason | usage of certificate rejected

#### Instances

Instances details

Eq CertificateUsage # |
Instance details Defined in Network.TLS.X509 Methods (==) :: CertificateUsage -> CertificateUsage -> Bool # (/=) :: CertificateUsage -> CertificateUsage -> Bool #
Show CertificateUsage # |
Instance details Defined in Network.TLS.X509 Methods showsPrec :: Int -> CertificateUsage -> ShowS # show :: CertificateUsage -> String # showList :: [CertificateUsage] -> ShowS #

data CertificateRejectReason #

Certificate and Chain rejection reason

Constructors

CertificateRejectExpired |
CertificateRejectRevoked |
CertificateRejectUnknownCA |
CertificateRejectAbsent |
CertificateRejectOther String |

#### Instances

Instances details

Eq CertificateRejectReason # |
Instance details Defined in Network.TLS.X509 Methods (==) :: CertificateRejectReason -> CertificateRejectReason -> Bool # (/=) :: CertificateRejectReason -> CertificateRejectReason -> Bool #
Show CertificateRejectReason # |
Instance details Defined in Network.TLS.X509 Methods showsPrec :: Int -> CertificateRejectReason -> ShowS # show :: CertificateRejectReason -> String # showList :: [CertificateRejectReason] -> ShowS #

data CertificateType #

Some of the IANA registered code points for `CertificateType` are not currently supported by the library. Nor should they be, they're are either unwise, obsolete or both. There's no point in conveying these to the user in the client certificate request callback. The request callback will be filtered to exclude unsupported values. If the user cannot find a certificate for a supported code point, we'll go ahead without a client certificate and hope for the best, unless the user's callback decides to throw an exception.

Constructors

CertificateType_RSA_Sign | TLS10 and up, RFC5246
CertificateType_DSS_Sign | TLS10 and up, RFC5246
CertificateType_ECDSA_Sign | TLS10 and up, RFC8422
CertificateType_Ed25519_Sign | TLS13 and up, synthetic
CertificateType_Ed448_Sign | TLS13 and up, synthetic | None of the below will ever be presented to the callback. Any future public key algorithms valid for client certificates go above this line.
CertificateType_RSA_Fixed_DH |
CertificateType_DSS_Fixed_DH |
CertificateType_RSA_Ephemeral_DH |
CertificateType_DSS_Ephemeral_DH |
CertificateType_fortezza_dms |
CertificateType_RSA_Fixed_ECDH |
CertificateType_ECDSA_Fixed_ECDH |
CertificateType_Unknown Word8 |

#### Instances

Instances details

Eq CertificateType # |
Instance details Defined in Network.TLS.Struct Methods (==) :: CertificateType -> CertificateType -> Bool # (/=) :: CertificateType -> CertificateType -> Bool #
Ord CertificateType # |
Instance details Defined in Network.TLS.Struct Methods compare :: CertificateType -> CertificateType -> Ordering # (<) :: CertificateType -> CertificateType -> Bool # (<=) :: CertificateType -> CertificateType -> Bool # (>) :: CertificateType -> CertificateType -> Bool # (>=) :: CertificateType -> CertificateType -> Bool # max :: CertificateType -> CertificateType -> CertificateType # min :: CertificateType -> CertificateType -> CertificateType #
Show CertificateType # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> CertificateType -> ShowS # show :: CertificateType -> String # showList :: [CertificateType] -> ShowS #

type HostName = String #

data MaxFragmentEnum #

Constructors

MaxFragment512 |
MaxFragment1024 |
MaxFragment2048 |
MaxFragment4096 |

#### Instances

Instances details

Eq MaxFragmentEnum # |
Instance details Defined in Network.TLS.Extension Methods (==) :: MaxFragmentEnum -> MaxFragmentEnum -> Bool # (/=) :: MaxFragmentEnum -> MaxFragmentEnum -> Bool #
Show MaxFragmentEnum # |
Instance details Defined in Network.TLS.Extension Methods showsPrec :: Int -> MaxFragmentEnum -> ShowS # show :: MaxFragmentEnum -> String # showList :: [MaxFragmentEnum] -> ShowS #

# Advanced APIs

## Backend

ctxConnection :: Context -> Backend #

return the backend object associated with this context

contextFlush :: Context -> IO () #

A shortcut for 'backendFlush . ctxConnection'.

contextClose :: Context -> IO () #

A shortcut for 'backendClose . ctxConnection'.

## Information gathering

data Information #

Information related to a running context, e.g. current cipher

Constructors

Information |
Fields infoVersion :: Version infoCipher :: Cipher infoCompression :: Compression infoMasterSecret :: Maybe ByteString infoExtendedMasterSec :: Bool infoClientRandom :: Maybe ClientRandom infoServerRandom :: Maybe ServerRandom infoNegotiatedGroup :: Maybe Group infoTLS13HandshakeMode :: Maybe HandshakeMode13 infoIsEarlyDataAccepted :: Bool

#### Instances

Instances details

Eq Information # |
Instance details Defined in Network.TLS.Context.Internal Methods (==) :: Information -> Information -> Bool # (/=) :: Information -> Information -> Bool #
Show Information # |
Instance details Defined in Network.TLS.Context.Internal Methods showsPrec :: Int -> Information -> ShowS # show :: Information -> String # showList :: [Information] -> ShowS #

contextGetInformation :: Context -> IO (Maybe Information) #

Information about the current context

data ClientRandom #

#### Instances

Instances details

Eq ClientRandom # |
Instance details Defined in Network.TLS.Struct Methods (==) :: ClientRandom -> ClientRandom -> Bool # (/=) :: ClientRandom -> ClientRandom -> Bool #
Show ClientRandom # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> ClientRandom -> ShowS # show :: ClientRandom -> String # showList :: [ClientRandom] -> ShowS #

data ServerRandom #

#### Instances

Instances details

Eq ServerRandom # |
Instance details Defined in Network.TLS.Struct Methods (==) :: ServerRandom -> ServerRandom -> Bool # (/=) :: ServerRandom -> ServerRandom -> Bool #
Show ServerRandom # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> ServerRandom -> ShowS # show :: ServerRandom -> String # showList :: [ServerRandom] -> ShowS #

unClientRandom :: ClientRandom -> ByteString #

unServerRandom :: ServerRandom -> ByteString #

data HandshakeMode13 #

Type to show which handshake mode is used in TLS 1.3.

Constructors

FullHandshake | Full handshake is used.
HelloRetryRequest | Full handshake is used with hello retry request.
PreSharedKey | Server authentication is skipped.
RTT0 | Server authentication is skipped and early data is sent.

#### Instances

Instances details

Eq HandshakeMode13 # |
Instance details Defined in Network.TLS.Handshake.State Methods (==) :: HandshakeMode13 -> HandshakeMode13 -> Bool # (/=) :: HandshakeMode13 -> HandshakeMode13 -> Bool #
Show HandshakeMode13 # |
Instance details Defined in Network.TLS.Handshake.State Methods showsPrec :: Int -> HandshakeMode13 -> ShowS # show :: HandshakeMode13 -> String # showList :: [HandshakeMode13] -> ShowS #

getClientCertificateChain :: Context -> IO (Maybe CertificateChain) #

Getting certificates from a client, if any. Note that the certificates are not sent by a client on resumption even if client authentication is required. So, this API would be replaced by the one which can treat both cases of full-negotiation and resumption.

## Negotiated

getNegotiatedProtocol :: MonadIO m => Context -> m (Maybe ByteString) #

If the ALPN extensions have been used, this will return get the protocol agreed upon.

getClientSNI :: MonadIO m => Context -> m (Maybe HostName) #

If the Server Name Indication extension has been used, return the hostname specified by the client.

## Post-handshake actions

updateKey :: MonadIO m => Context -> KeyUpdateRequest -> m Bool #

Updating appication traffic secrets for TLS 1.3. If this API is called for TLS 1.3, `True` is returned. Otherwise, `False` is returned.

data KeyUpdateRequest #

How to update keys in TLS 1.3

Constructors

OneWay | Unidirectional key update
TwoWay | Bidirectional key update (normal case)

#### Instances

Instances details

Eq KeyUpdateRequest # |
Instance details Defined in Network.TLS.Core Methods (==) :: KeyUpdateRequest -> KeyUpdateRequest -> Bool # (/=) :: KeyUpdateRequest -> KeyUpdateRequest -> Bool #
Show KeyUpdateRequest # |
Instance details Defined in Network.TLS.Core Methods showsPrec :: Int -> KeyUpdateRequest -> ShowS # show :: KeyUpdateRequest -> String # showList :: [KeyUpdateRequest] -> ShowS #

requestCertificate :: MonadIO m => Context -> m Bool #

Post-handshake certificate request with TLS 1.3. Returns `True` if the request was possible, i.e. if TLS 1.3 is used and the remote client supports post-handshake authentication.

## Modifying hooks in context

data Hooks #

A collection of hooks actions.

Constructors

Hooks |
Fields hookRecvHandshake :: Handshake -> IO Handshake called at each handshake message received hookRecvHandshake13 :: Handshake13 -> IO Handshake13 called at each handshake message received for TLS 1.3 hookRecvCertificates :: CertificateChain -> IO () called at each certificate chain message received hookLogging :: Logging hooks on IO and packets, receiving and sending.

#### Instances

Instances details

Default Hooks # |
Instance details Defined in Network.TLS.Hooks Methods def :: Hooks #

contextModifyHooks :: Context -> (Hooks -> Hooks) -> IO () #

data Handshake #

#### Instances

Instances details

Eq Handshake # |
Instance details Defined in Network.TLS.Struct Methods (==) :: Handshake -> Handshake -> Bool # (/=) :: Handshake -> Handshake -> Bool #
Show Handshake # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> Handshake -> ShowS # show :: Handshake -> String # showList :: [Handshake] -> ShowS #

contextHookSetHandshakeRecv :: Context -> (Handshake -> IO Handshake) -> IO () #

data Handshake13 #

#### Instances

Instances details

Eq Handshake13 # |
Instance details Defined in Network.TLS.Struct13 Methods (==) :: Handshake13 -> Handshake13 -> Bool # (/=) :: Handshake13 -> Handshake13 -> Bool #
Show Handshake13 # |
Instance details Defined in Network.TLS.Struct13 Methods showsPrec :: Int -> Handshake13 -> ShowS # show :: Handshake13 -> String # showList :: [Handshake13] -> ShowS #

contextHookSetHandshake13Recv :: Context -> (Handshake13 -> IO Handshake13) -> IO () #

contextHookSetCertificateRecv :: Context -> (CertificateChain -> IO ()) -> IO () #

data Logging #

Hooks for logging

This is called when sending and receiving packets and IO

Constructors

Logging |
Fields loggingPacketSent :: String -> IO () loggingPacketRecv :: String -> IO () loggingIOSent :: ByteString -> IO () loggingIORecv :: Header -> ByteString -> IO ()

#### Instances

Instances details

Default Logging # |
Instance details Defined in Network.TLS.Hooks Methods def :: Logging #

data Header #

Constructors

Header ProtocolType Version Word16 |

#### Instances

Instances details

Eq Header # |
Instance details Defined in Network.TLS.Struct Methods (==) :: Header -> Header -> Bool # (/=) :: Header -> Header -> Bool #
Show Header # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> Header -> ShowS # show :: Header -> String # showList :: [Header] -> ShowS #

data ProtocolType #

Constructors

ProtocolType_ChangeCipherSpec |
ProtocolType_Alert |
ProtocolType_Handshake |
ProtocolType_AppData |
ProtocolType_DeprecatedHandshake |

#### Instances

Instances details

Eq ProtocolType # |
Instance details Defined in Network.TLS.Struct Methods (==) :: ProtocolType -> ProtocolType -> Bool # (/=) :: ProtocolType -> ProtocolType -> Bool #
Show ProtocolType # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> ProtocolType -> ShowS # show :: ProtocolType -> String # showList :: [ProtocolType] -> ShowS #

contextHookSetLogging :: Context -> Logging -> IO () #

# Errors and exceptions

## Errors

data TLSError #

TLSError that might be returned through the TLS stack

Constructors

Error_Misc String | mainly for instance of Error
Error_Protocol (String, Bool, AlertDescription) |
Error_Certificate String |
Error_HandshakePolicy String | handshake policy failed.
Error_EOF |
Error_Packet String |
Error_Packet_unexpected String String |
Error_Packet_Parsing String |

#### Instances

Instances details

Eq TLSError # |
Instance details Defined in Network.TLS.Struct Methods (==) :: TLSError -> TLSError -> Bool # (/=) :: TLSError -> TLSError -> Bool #
Show TLSError # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> TLSError -> ShowS # show :: TLSError -> String # showList :: [TLSError] -> ShowS #
Exception TLSError # |
Instance details Defined in Network.TLS.Struct Methods toException :: TLSError -> SomeException # fromException :: SomeException -> Maybe TLSError # displayException :: TLSError -> String #

data KxError #

Constructors

RSAError Error |
KxUnsupported |

#### Instances

Instances details

Show KxError # |
Instance details Defined in Network.TLS.Crypto Methods showsPrec :: Int -> KxError -> ShowS # show :: KxError -> String # showList :: [KxError] -> ShowS #

data AlertDescription #

Constructors

CloseNotify |
UnexpectedMessage |
BadRecordMac |
DecryptionFailed | deprecated alert, should never be sent by compliant implementation
RecordOverflow |
DecompressionFailure |
HandshakeFailure |
BadCertificate |
UnsupportedCertificate |
CertificateRevoked |
CertificateExpired |
CertificateUnknown |
IllegalParameter |
UnknownCa |
AccessDenied |
DecodeError |
DecryptError |
ExportRestriction |
ProtocolVersion |
InsufficientSecurity |
InternalError |
InappropriateFallback |
UserCanceled |
NoRenegotiation |
MissingExtension |
UnsupportedExtension |
CertificateUnobtainable |
UnrecognizedName |
BadCertificateStatusResponse |
BadCertificateHashValue |
UnknownPskIdentity |
CertificateRequired |
NoApplicationProtocol |

#### Instances

Instances details

Eq AlertDescription # |
Instance details Defined in Network.TLS.Struct Methods (==) :: AlertDescription -> AlertDescription -> Bool # (/=) :: AlertDescription -> AlertDescription -> Bool #
Show AlertDescription # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> AlertDescription -> ShowS # show :: AlertDescription -> String # showList :: [AlertDescription] -> ShowS #

## Exceptions

data TLSException #

TLS Exceptions related to bad user usage or asynchronous errors

Constructors

Terminated Bool String TLSError | Early termination exception with the reason and the error associated
HandshakeFailed TLSError | Handshake failed for the reason attached
ConnectionNotEstablished | Usage error when the connection has not been established and the user is trying to send or receive data

#### Instances

Instances details

Eq TLSException # |
Instance details Defined in Network.TLS.Struct Methods (==) :: TLSException -> TLSException -> Bool # (/=) :: TLSException -> TLSException -> Bool #
Show TLSException # |
Instance details Defined in Network.TLS.Struct Methods showsPrec :: Int -> TLSException -> ShowS # show :: TLSException -> String # showList :: [TLSException] -> ShowS #
Exception TLSException # |
Instance details Defined in Network.TLS.Struct Methods toException :: TLSException -> SomeException # fromException :: SomeException -> Maybe TLSException # displayException :: TLSException -> String #

# Raw types

## Compressions class

class CompressionC a where #

supported compression algorithms need to be part of this class

Methods

compressionCID :: a -> CompressionID #

compressionCDeflate :: a -> ByteString -> (a, ByteString) #

compressionCInflate :: a -> ByteString -> (a, ByteString) #

type CompressionID = Word8 #

Compression identification

## Crypto Key

data PubKey #

Public key types known and used in X.509

Constructors

PubKeyRSA PublicKey | RSA public key
PubKeyDSA PublicKey | DSA public key
PubKeyDH (Integer, Integer, Integer, Maybe Integer, ([Word8], Integer)) | DH format with (p,g,q,j,(seed,pgenCounter))
PubKeyEC PubKeyEC | EC public key
PubKeyX25519 PublicKey | X25519 public key
PubKeyX448 PublicKey | X448 public key
PubKeyEd25519 PublicKey | Ed25519 public key
PubKeyEd448 PublicKey | Ed448 public key
PubKeyUnknown OID ByteString | unrecognized format

#### Instances

Instances details

Eq PubKey |
Instance details Defined in Data.X509.PublicKey Methods (==) :: PubKey -> PubKey -> Bool # (/=) :: PubKey -> PubKey -> Bool #
Show PubKey |
Instance details Defined in Data.X509.PublicKey Methods showsPrec :: Int -> PubKey -> ShowS # show :: PubKey -> String # showList :: [PubKey] -> ShowS #
ASN1Object PubKey |
Instance details Defined in Data.X509.PublicKey Methods toASN1 :: PubKey -> ASN1S # fromASN1 :: [ASN1] -> Either String (PubKey, [ASN1]) #

data PrivKey #

Private key types known and used in X.509

Constructors

PrivKeyRSA PrivateKey | RSA private key
PrivKeyDSA PrivateKey | DSA private key
PrivKeyEC PrivKeyEC | EC private key
PrivKeyX25519 SecretKey | X25519 private key
PrivKeyX448 SecretKey | X448 private key
PrivKeyEd25519 SecretKey | Ed25519 private key
PrivKeyEd448 SecretKey | Ed448 private key

#### Instances

Instances details

Eq PrivKey |
Instance details Defined in Data.X509.PrivateKey Methods (==) :: PrivKey -> PrivKey -> Bool # (/=) :: PrivKey -> PrivKey -> Bool #
Show PrivKey |
Instance details Defined in Data.X509.PrivateKey Methods showsPrec :: Int -> PrivKey -> ShowS # show :: PrivKey -> String # showList :: [PrivKey] -> ShowS #
ASN1Object PrivKey |
Instance details Defined in Data.X509.PrivateKey Methods toASN1 :: PrivKey -> ASN1S # fromASN1 :: [ASN1] -> Either String (PrivKey, [ASN1]) #

## Ciphers & Predefined ciphers

data CipherKeyExchangeType #

Constructors

CipherKeyExchange_RSA |
CipherKeyExchange_DH_Anon |
CipherKeyExchange_DHE_RSA |
CipherKeyExchange_ECDHE_RSA |
CipherKeyExchange_DHE_DSS |
CipherKeyExchange_DH_DSS |
CipherKeyExchange_DH_RSA |
CipherKeyExchange_ECDH_ECDSA |
CipherKeyExchange_ECDH_RSA |
CipherKeyExchange_ECDHE_ECDSA |
CipherKeyExchange_TLS13 |

#### Instances

Instances details

Eq CipherKeyExchangeType # |
Instance details Defined in Network.TLS.Cipher Methods (==) :: CipherKeyExchangeType -> CipherKeyExchangeType -> Bool # (/=) :: CipherKeyExchangeType -> CipherKeyExchangeType -> Bool #
Show CipherKeyExchangeType # |
Instance details Defined in Network.TLS.Cipher Methods showsPrec :: Int -> CipherKeyExchangeType -> ShowS # show :: CipherKeyExchangeType -> String # showList :: [CipherKeyExchangeType] -> ShowS #

data Bulk #

Constructors

Bulk |
Fields bulkName :: String bulkKeySize :: Int bulkIVSize :: Int bulkExplicitIV :: Int bulkAuthTagLen :: Int bulkBlockSize :: Int bulkF :: BulkFunctions

#### Instances

Instances details

Eq Bulk # |
Instance details Defined in Network.TLS.Cipher Methods (==) :: Bulk -> Bulk -> Bool # (/=) :: Bulk -> Bulk -> Bool #
Show Bulk # |
Instance details Defined in Network.TLS.Cipher Methods showsPrec :: Int -> Bulk -> ShowS # show :: Bulk -> String # showList :: [Bulk] -> ShowS #

data BulkFunctions #

Constructors

BulkBlockF (BulkDirection -> BulkKey -> BulkBlock) |
BulkStreamF (BulkDirection -> BulkKey -> BulkStream) |
BulkAeadF (BulkDirection -> BulkKey -> BulkAEAD) |

data BulkDirection #

Constructors

BulkEncrypt |
BulkDecrypt |

#### Instances

Instances details

Eq BulkDirection # |
Instance details Defined in Network.TLS.Cipher Methods (==) :: BulkDirection -> BulkDirection -> Bool # (/=) :: BulkDirection -> BulkDirection -> Bool #
Show BulkDirection # |
Instance details Defined in Network.TLS.Cipher Methods showsPrec :: Int -> BulkDirection -> ShowS # show :: BulkDirection -> String # showList :: [BulkDirection] -> ShowS #

data BulkState #

Constructors

BulkStateStream BulkStream |
BulkStateBlock BulkBlock |
BulkStateAEAD BulkAEAD |
BulkStateUninitialized |

#### Instances

Instances details

Show BulkState # |
Instance details Defined in Network.TLS.Cipher Methods showsPrec :: Int -> BulkState -> ShowS # show :: BulkState -> String # showList :: [BulkState] -> ShowS #

newtype BulkStream #

Constructors

BulkStream (ByteString -> (ByteString, BulkStream)) |

type BulkBlock = BulkIV -> ByteString -> (ByteString, BulkIV) #

type BulkAEAD = BulkNonce -> ByteString -> BulkAdditionalData -> (ByteString, AuthTag) #

bulkInit :: Bulk -> BulkDirection -> BulkKey -> BulkState #

data Hash #

Constructors

MD5 |
SHA1 |
SHA224 |
SHA256 |
SHA384 |
SHA512 |
SHA1_MD5 |

#### Instances

Instances details

Eq Hash # |
Instance details Defined in Network.TLS.Crypto Methods (==) :: Hash -> Hash -> Bool # (/=) :: Hash -> Hash -> Bool #
Show Hash # |
Instance details Defined in Network.TLS.Crypto Methods showsPrec :: Int -> Hash -> ShowS # show :: Hash -> String # showList :: [Hash] -> ShowS #

data Cipher #

Cipher algorithm

Constructors

Cipher |
Fields cipherID :: CipherID cipherName :: String cipherHash :: Hash cipherBulk :: Bulk cipherKeyExchange :: CipherKeyExchangeType cipherMinVer :: Maybe Version cipherPRFHash :: Maybe Hash

#### Instances

Instances details

Eq Cipher # |
Instance details Defined in Network.TLS.Cipher Methods (==) :: Cipher -> Cipher -> Bool # (/=) :: Cipher -> Cipher -> Bool #
Show Cipher # |
Instance details Defined in Network.TLS.Cipher Methods showsPrec :: Int -> Cipher -> ShowS # show :: Cipher -> String # showList :: [Cipher] -> ShowS #

type CipherID = Word16 #

Cipher identification

cipherKeyBlockSize :: Cipher -> Int #

type BulkKey = ByteString #

type BulkIV = ByteString #

type BulkNonce = ByteString #

type BulkAdditionalData = ByteString #

cipherAllowedForVersion :: Version -> Cipher -> Bool #

Check if a specific `Cipher` is allowed to be used with the version specified

hasMAC :: BulkFunctions -> Bool #

hasRecordIV :: BulkFunctions -> Bool #

# Deprecated

recvData' :: MonadIO m => Context -> m ByteString #

Deprecated: use recvData that returns strict bytestring

same as recvData but returns a lazy bytestring.

contextNewOnHandle #

Arguments

:: (MonadIO m, TLSParams params) |
=> Handle | Handle of the connection.
-> params | Parameters of the context.
-> m Context |

Deprecated: use contextNew

create a new context on an handle.

contextNewOnSocket #

Arguments

:: (MonadIO m, TLSParams params) |
=> Socket | Socket of the connection.
-> params | Parameters of the context.
-> m Context |

Deprecated: use contextNew

create a new context on a socket.

type Bytes = ByteString #

Deprecated: Use Data.ByteString.Bytestring instead of Bytes.

data ValidationChecks #

A set of checks to activate or parametrize to perform on certificates.

It's recommended to use `defaultChecks` to create the structure, to better cope with future changes or expansion of the structure.

Constructors

ValidationChecks |
Fields checkTimeValidity :: Bool check time validity of every certificate in the chain. the make sure that current time is between each validity bounds in the certificate checkAtTime :: Maybe DateTime The time when the validity check happens. When set to Nothing, the current time will be used checkStrictOrdering :: Bool Check that no certificate is included that shouldn't be included. unfortunately despite the specification violation, a lots of real world server serves useless and usually old certificates that are not relevant to the certificate sent, in their chain. checkCAConstraints :: Bool Check that signing certificate got the CA basic constraint. this is absolutely not recommended to turn it off. checkExhaustive :: Bool Check the whole certificate chain without stopping at the first failure. Allow gathering a exhaustive list of failure reasons. if this is turn off, it's absolutely not safe to ignore a failed reason even it doesn't look serious (e.g. Expired) as other more serious checks would not have been performed. checkLeafV3 :: Bool Check that the leaf certificate is version 3. If disable, version 2 certificate is authorized in leaf position and key usage cannot be checked. checkLeafKeyUsage :: [ExtKeyUsageFlag] Check that the leaf certificate is authorized to be used for certain usage. If set to empty list no check are performed, otherwise all the flags is the list need to exists in the key usage extension. If the extension is not present, the check will pass and behave as if the certificate key is not restricted to any specific usage. checkLeafKeyPurpose :: [ExtKeyUsagePurpose] Check that the leaf certificate is authorized to be used for certain purpose. If set to empty list no check are performed, otherwise all the flags is the list need to exists in the extended key usage extension if present. If the extension is not present, then the check will pass and behave as if the certificate is not restricted to any specific purpose. checkFQHN :: Bool Check the top certificate names matching the fully qualified hostname (FQHN). it's not recommended to turn this check off, if no other name checks are performed.

#### Instances

Instances details

Eq ValidationChecks |
Instance details Defined in Data.X509.Validation Methods (==) :: ValidationChecks -> ValidationChecks -> Bool # (/=) :: ValidationChecks -> ValidationChecks -> Bool #
Show ValidationChecks |
Instance details Defined in Data.X509.Validation Methods showsPrec :: Int -> ValidationChecks -> ShowS # show :: ValidationChecks -> String # showList :: [ValidationChecks] -> ShowS #
Default ValidationChecks |
Instance details Defined in Data.X509.Validation Methods def :: ValidationChecks #

data ValidationHooks #

A set of hooks to manipulate the way the verification works.

BEWARE, it's easy to change behavior leading to compromised security.

Constructors

ValidationHooks |
Fields hookMatchSubjectIssuer :: DistinguishedName -> Certificate -> Bool check whether a given issuer `DistinguishedName` matches the subject `DistinguishedName` of a candidate issuer certificate. hookValidateTime :: DateTime -> Certificate -> [FailedReason] check whether the certificate in the second argument is valid at the time provided in the first argument. Return an empty list for success or else one or more failure reasons. hookValidateName :: HostName -> Certificate -> [FailedReason] validate the certificate leaf name with the DNS named used to connect hookFilterReason :: [FailedReason] -> [FailedReason] user filter to modify the list of failure reasons

#### Instances

Instances details

Default ValidationHooks |
Instance details Defined in Data.X509.Validation Methods def :: ValidationHooks #