Create cache before writing ca_certs. Fixes #343.