Skip to content

adetokunbo/test-certs

Repository files navigation

test-certs

GitHub CI Stackage Nightly Hackage Hackage Dependencies BSD3

test-certs provides functions that generate temporary SSL certificates for tests.

Its functions generate the certificates as files in a temporary directory

Note: this package depends on HsOpenSSL. It expects the openssl system libraries to be available on your system; this is usually the case on most modern linux distributions.

It's intended for use with warp-tls or similar packages

Example (wai/warp-tls)

import Test.Certs.Temp (certificatePath, keyPath, withCertPathsInTmp')
import Network.Wai (Application) -- from package: wai
import Network.Wai.Handler.Warp (Settings) -- from package: warp
import Network.Wai.Handler.WarpTLS (runTLS, tlsSettings) -- from package: warp-tls

-- | Like 'runTLS', but with temporary certificates generated by test-certs
runTLS' :: Settings -> Application -> IO ()
runTLS' appSettings app = withCertPathsInTmp' $ \cp -> do
  let tls = tlsSettings (certificatePath cp) (keyPath cp)
  runTLS tls appSettings app

About

A haskell package to generate tempororary SSL certificates for use in tests

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published