@@ -15,20 +15,22 @@
15module Network.Wai.Handler.WarpTLS (
15module Network.Wai.Handler.WarpTLS (
16 -- * Settings
16 -- * Settings
17 TLSSettings
17 TLSSettings
18 , certFile
20 , certFile
21 , tlsLogging
22 , tlsLogging
22 , tlsAllowedVersions
23 , tlsAllowedVersions
23 , tlsCiphers
24 , tlsCiphers
24 , tlsWantClientCert
25 , tlsWantClientCert
25 , tlsServerHooks
26 , tlsServerHooks
26− , defaultTlsSettings
27+ , onInsecure
29+ -- * Smart constructors
27 , tlsSettings
30 , tlsSettings
28 , tlsSettingsMemory
31 , tlsSettingsMemory
29 , tlsSettingsChain
32 , tlsSettingsChain
30 , tlsSettingsChainMemory
33 , tlsSettingsChainMemory
32 -- * Runner
34 -- * Runner
34 , runTLSSocket
36 , runTLSSocket
@@ -59,6 +61,7 @@ import System.IO.Error (isEOFError)
60----------------------------------------------------------------
62----------------------------------------------------------------
64+-- | Settings for WarpTLS.
62data TLSSettings = TLSSettings {
65data TLSSettings = TLSSettings {
63 certFile :: FilePath
66 certFile :: FilePath
64 -- ^ File containing the certificate.
67 -- ^ File containing the certificate.
@@ -70,8 +73,10 @@ data TLSSettings = TLSSettings {
70 , chainCertsMemory :: [S.ByteString]
73 , chainCertsMemory :: [S.ByteString]
71 , keyMemory :: Maybe S.ByteString
74 , keyMemory :: Maybe S.ByteString
72 , onInsecure :: OnInsecure
75 , onInsecure :: OnInsecure
73− -- ^ Do we allow insecure connections with this server as well? Default
76+ -- ^ Do we allow insecure connections with this server as well?
74− -- is a simple text response stating that a secure connection is required.
77+ --
78+ -- >>> onInsecure defaultTlsSettings
79+ -- DenyInsecure "This server only accepts secure HTTPS connections."
76 -- Since 1.4.0
81 -- Since 1.4.0
77 , tlsLogging :: TLS.Logging
82 , tlsLogging :: TLS.Logging
@@ -83,13 +88,15 @@ data TLSSettings = TLSSettings {
83 , tlsAllowedVersions :: [TLS.Version]
88 , tlsAllowedVersions :: [TLS.Version]
84 -- ^ The TLS versions this server accepts.
89 -- ^ The TLS versions this server accepts.
86− -- Default: '[TLS.TLS10,TLS.TLS11,TLS.TLS12]'.
91+ -- >>> tlsAllowedVersions defaultTlsSettings
92+ -- [TLS12,TLS11,TLS10]
88 -- Since 1.4.2
94 -- Since 1.4.2
89 , tlsCiphers :: [TLS.Cipher]
95 , tlsCiphers :: [TLS.Cipher]
90 -- ^ The TLS ciphers this server accepts.
96 -- ^ The TLS ciphers this server accepts.
92− -- Default: '[TLSExtra.cipher_AES128_SHA1, TLSExtra.cipher_AES256_SHA1, TLSEtra.cipher_RC4_128_MD5, TLSExtra.cipher_RC4_128_SHA1]'
98+ -- >>> tlsCiphers defaultTlsSettings
99+ -- [ECDHE-RSA-AES128GCM-SHA256,DHE-RSA-AES128GCM-SHA256,DHE-RSA-AES256-SHA256,DHE-RSA-AES128-SHA256,DHE-RSA-AES256-SHA1,DHE-RSA-AES128-SHA1,DHE-DSA-AES128-SHA1,DHE-DSA-AES256-SHA1,DHE-DSA-RC4-SHA1,RSA-aes128-sha1,RSA-aes256-sha1,RSA-rc4-128-md5,RSA-rc4-128-sha1]
94 -- Since 1.4.2
101 -- Since 1.4.2
95 , tlsWantClientCert :: Bool
102 , tlsWantClientCert :: Bool
@@ -97,7 +104,8 @@ data TLSSettings = TLSSettings {
97 -- is set to True, you must handle received certificates in a server hook
104 -- is set to True, you must handle received certificates in a server hook
98 -- or all connections will fail.
105 -- or all connections will fail.
107+ -- >>> tlsWantClientCert defaultTlsSettings
100− -- Default: False
108+ -- False
102 -- Since 3.0.2
110 -- Since 3.0.2
103 , tlsServerHooks :: TLS.ServerHooks
111 , tlsServerHooks :: TLS.ServerHooks
@@ -110,7 +118,7 @@ data TLSSettings = TLSSettings {
110 -- Since 3.0.2
118 -- Since 3.0.2
113−-- | Default 'TLSSettings'. Use this to create 'TLSSettings' with the field record name.
121+-- | Default 'TLSSettings'. Use this to create 'TLSSettings' with the field record name (aka accessors).
114defaultTlsSettings :: TLSSettings
122defaultTlsSettings :: TLSSettings
115defaultTlsSettings = TLSSettings {
123defaultTlsSettings = TLSSettings {
116 certFile = "certificate.pem"
124 certFile = "certificate.pem"
@@ -150,6 +158,7 @@ ciphers =
150-- | An action when a plain HTTP comes to HTTP over TLS/SSL port.
158-- | An action when a plain HTTP comes to HTTP over TLS/SSL port.
151data OnInsecure = DenyInsecure L.ByteString
159data OnInsecure = DenyInsecure L.ByteString
152 | AllowInsecure
160 | AllowInsecure
154----------------------------------------------------------------
163----------------------------------------------------------------