http-client-rustls-0.0.0.0: http-client TLS backend using Rustls
Safe HaskellNone
LanguageHaskell2010

Network.HTTP.Client.Rustls

Description

Make HTTPS connections using http-client and Rustls.

>>> import qualified Rustls
>>> import qualified Network.HTTP.Client as HTTP
>>> :{
newRustlsManager :: IO HTTP.Manager
newRustlsManager = do
  clientConfig <-
    Rustls.buildClientConfig $ Rustls.defaultClientConfigBuilder roots
  HTTP.newManager $ rustlsManagerSettings clientConfig
  where
    -- For now, rustls-ffi does not provide a built-in way to access
    -- the OS certificate store.
    roots = Rustls.ClientRootsFromFile "/etc/ssl/certs/ca-certificates.crt"
>>> :}
>>> :{
example = do
  mgr <- newRustlsManager -- this should be shared across multiple requests
  req <- HTTP.parseUrlThrow "https://example.org"
  res <- HTTP.httpLbs req mgr
  print $ HTTP.responseBody res
:}
Synopsis

Documentation

rustlsManagerSettings :: ClientConfig -> ManagerSettings Source #

Get TLS-enabled HTTP ManagerSettings from a Rustls ClientConfig, consumable via newManager.