X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=examples%2FSSL.hs;h=f78b6c229939c49825fb6ab612ddf783066b3abf;hp=23de8b04062c4d6b48b80b2b525ae913aab7610c;hb=950640dd241222203778f8167943d30fa52f356a;hpb=9be2b946657c536a4363a076235f70728be087c4 diff --git a/examples/SSL.hs b/examples/SSL.hs index 23de8b0..f78b6c2 100644 --- a/examples/SSL.hs +++ b/examples/SSL.hs @@ -10,12 +10,14 @@ import Control.Monad.Unicode import qualified Data.ByteString.Lazy.Char8 as Lazy import qualified Data.Collections as C 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 $ @@ -37,21 +39,20 @@ main = withOpenSSL $ 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