4
I'm trying to provision a Vagrant box with a root CA and install it in Firefox. I've figured out that I can install the certificate using certutil
but the problem is it requires an existing Firefox profile to which to add the certificate.
On a fresh new box the profile is created the first time Firefox is run. This is problematic because Firefox won't run properly without a display, but that can be worked around by using the -headless
option. But this then needs to be killed manually. Since it takes a bit of time for it to create the new profile, it requires a hack using sleep
. Overall I've got the following:
#!/bin/bash
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install \
firefox \
libnss3-tools
# create a new profile
firefox -headless &
sleep 2
kill $!
# install the root CA into all profiles
cert="${HOME}/mycert.cer"
for certDb in $(find ${HOME}/.mozilla* -name "cert8.db"); do
certDir="$(dirname ${certDb})"
echo ${certDir}
certutil -A -n "mycert" -t "TCu,Cuw,Tuw" -i "${cert}" -d "${certDir}"
done
Is there a better way to do this without using sleep
and kill
?