I’m trying to start a flutter
app that was built with flutter-3.0.0
in a podman
container.
This app queries a web API on https on a server with a LetsEncrypt certificate.
I figured this is a similar issue where e.g. curl
or git
can’t find a valid CA-bundle (like on ancient systems where the system’s CA bundle doesn’t know about LetsEncrypt), so I additionally pulled in cacert
. It still doesn’t work, and I still get an error like this:
An error occurred which was forwarded to the root. ERROR: HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: unable to get local issuer certificate(handshake.cc:393))
The interwebs suggest all kinds of hacks in the flutter app, but in my case the app works everywhere except on nixos
. (I tried with steam-run
too, but that’s missing libepoxy
)
What is the “official” way to add the correct CA-bundle to a pure nix-shell
?
Now it looks like this:
### !!! To make this work, we have to run it in pure mode (otherwise the lib path is not overridden/enforced?)
### !!! But: certificates don't appear to work in a pure env? (Because the CA-bundle is not found and it's not clear where it's put)
### Also there is no info whether flutter apps use an env var to point to a CA bundle, so would the following be necessary to work around unavailable certs?
### https://stackoverflow.com/a/69481863/12771809
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
name = "flutterapp";
targetPkgs = pkgs: with pkgs; [
thefuck lsd # to mimick our normal shell env // make aliases work
# cacert
# at-spi2-core # not explicitly necessary? But how to forward DBUS to pure?
util-linux
harfbuzz zlib glib libepoxy atk
cairo pango gdk-pixbuf gtk3
xorg.libXdmcp xorg.libXtst
libselinux libsepol libthai libxkbcommon
];
runScript = "${pkgs.zsh}/bin/zsh";
profile = ''
export SSH_AUTH_SOCK=/run/user/$UID/keyring/ssh
export GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
export CURL_CA_BUNDLE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
unset TZ # use /etc/localtime (as fallback) which is correct
'';
}).env