import Control.Monad.Unicode
import qualified Data.ByteString.Lazy.Char8 as Lazy
import qualified Data.Collections as C
+import Data.Default
import Data.Time.Clock
+import Network
import Network.HTTP.Lucu
import OpenSSL
import OpenSSL.EVP.PKey
import OpenSSL.RSA
import qualified OpenSSL.Session as SSL
import OpenSSL.X509
+import Prelude.Unicode
main ∷ IO ()
main = withOpenSSL $
SSL.contextSetCertificate ctx cert
SSL.contextSetDefaultCiphers ctx
- let config = defaultConfig {
+ let config = def {
cnfServerPort = "9000"
, cnfSSLConfig = Just SSLConfig {
sslServerPort = "9001"
tree ∷ ResourceTree
tree = C.fromList [ ([], nonGreedy helloWorld) ]
putStrLn "Access https://localhost:9001/ with your browser."
- runHttpd config $ resourceMap tree
+ withSocketsDo ∘ runHttpd config $ resourceMap tree
helloWorld ∷ Resource
helloWorld
- = C.fromList
- [ ( GET
- , do setContentType [mimeType| text/plain |]
- putChunk "getRemoteCertificate = "
- cert ← do cert ← getRemoteCertificate
- case cert of
- Just c → liftIO $ Lazy.pack <$> printX509 c
- Nothing → return "Nothing"
- putChunks cert
- )
- ]
+ = C.singleton
+ ( GET
+ , do setContentType [mimeType| text/plain |]
+ putChunk "getRemoteCertificate = "
+ cert ← do cert ← getRemoteCertificate
+ case cert of
+ Just c → liftIO $ Lazy.pack <$> printX509 c
+ Nothing → return "Nothing"
+ putChunks cert
+ )
genCert ∷ KeyPair k ⇒ k → IO X509
genCert pkey