diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix
index 6bacba73f1e7..b889c4f24583 100644
--- a/pkgs/build-support/rust/default.nix
+++ b/pkgs/build-support/rust/default.nix
@@ -44,6 +44,7 @@ in stdenv.mkDerivation (args // {
 
     export CARGO_HOME="$(realpath deps)"
     export RUST_LOG=${logLevel}
+    export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
 
     # Let's find out which $indexHash cargo uses for file:///dev/null
     (cd $sourceRoot && cargo fetch &>/dev/null) || true
diff --git a/pkgs/build-support/rust/fetch-cargo-deps b/pkgs/build-support/rust/fetch-cargo-deps
index 4fbc53d1039e..54593994990f 100755
--- a/pkgs/build-support/rust/fetch-cargo-deps
+++ b/pkgs/build-support/rust/fetch-cargo-deps
@@ -147,7 +147,7 @@ EOF
             done
 
             # Create ad-hoc branches for the revs we need
-            echo "$revs" | while read rev; do
+            echo "$revs" | tr " " "\n" | while read -d " " rev; do
                 echo "Creating git branch b_$rev $rev"
                 git branch b_$rev $rev
             done