Haskell Stack throwing "certificate has unknown CA" exception

NixOS 20.09, ghc, stack and cacert packages included.

I try to build/test first haskell excercise from excercism.io and get following stack exception:

└➤ stack test
Exception while reading snapshot from lts-16.21:
HttpExceptionRequest Request {
  host                 = "raw.githubusercontent.com"
  port                 = 443
  secure               = True
  requestHeaders       = [("User-Agent","Haskell pantry package")]
  path                 = "/commercialhaskell/stackage-snapshots/master/lts/16/21.yaml"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (InternalException (HandshakeFailed (Error_Protocol ("certificate has unknown CA",True,UnknownCa))))

Seems like the stack package is unaware of certificates delivered by the cacert package. How can I fix that?

Details

Contents of stack.yaml:

resolver: lts-16.21

Steps to reproduce:

nix-shell -p ghc stack exercism cacert
exercism configure --token=[your-exercism.io-token]
exercism download --exercise=hello-world --track=haskell
cd ~/exercism/haskell/hello-world
stack test
2 Likes