I am trying to write an script (postinst for a .deb package) that will install a secure websockets (wss:) application and a certificate that allows access from the Chrome browser. The developer has this working by adding a certificate to the user's nssdb using certutil -A -d sql:$HOME/.pki/nssdb
How do I do this from an installer script? I've tried sudo -u $SUDO_USER, which works if the user uses the commandline sudo dpkg but doesn't work from something like Ubuntu Software Centre which runs as root. Is there a better way of doing it such as a system-wide database. I tried /etc/pki/nssdb which I'd seen somewhere but that wasn't being picked up by Chrome.