Skip to content

Instantly share code, notes, and snippets.

@FalconNL93
Last active February 6, 2024 07:49
Show Gist options
  • Save FalconNL93/6631a890a3f4882deecda4439b4f26af to your computer and use it in GitHub Desktop.
Save FalconNL93/6631a890a3f4882deecda4439b4f26af to your computer and use it in GitHub Desktop.
Root certificate ASP.NET Ubuntu
# Install Certutil
sudo apt-get install libnss3-tools
# Setup Firefox
PEMFILE="/usr/local/share/ca-certificates/aspnet/https.crt"
echo "{
\"policies\": {
\"Certificates\": {
\"Install\": [
\"aspnetcore-localhost-https.crt\"
]
}
}
}" > policies.json
dotnet dev-certs https --clean
sudo rm -rfv /usr/local/share/ca-certificates/localhost.crt \
/usr/local/share/ca-certificates/aspnet/https.crt \
$HOME/.mozilla/certificates/aspnetcore-localhost-https.crt \
/usr/lib/ssl/certs/aspnetcore-https-localhost.pem \
/etc/ssl/certs/aspnetcore-https-localhost.pem \
/etc/ssl/certs/localhost.pem
sudo update-ca-certificates
dotnet dev-certs https
sudo -E $HOME/.dotnet/dotnet dev-certs https -ep ${PEMFILE} --format PEM
sudo mv policies.json /usr/lib/firefox/distribution/
mkdir -p ~/.mozilla/certificates
sudo cp ${PEMFILE} ~/.mozilla/certificates/aspnetcore-localhost-https.crt
sudo chown $USER:$USER ~/.mozilla/certificates/aspnetcore-localhost-https.crt
# Trust Edge/Chrome
sudo certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n localhost -i ${PEMFILE}
sudo certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n localhost -i ${PEMFILE}
# Trust dotnet-to-dotnet (.pem extension is important here)
sudo cp ${PEMFILE} /usr/lib/ssl/certs/aspnetcore-https-localhost.pem
# Trust localhost root certificate
sudo cp ${PEMFILE} /usr/local/share/ca-certificates
sudo update-ca-certificates
# /usr/lib64/firefox/distribution/policies.json
#{
# "policies": {
# "Certificates": {
# "Install": [
# "localhost.crt"
# ]
# }
# }
#}
#!/bin/bash
DEV_CERT="$HOME/aspnet-$USER.pem"
dotnet dev-certs https --clean
dotnet dev-certs https -ep "$DEV_CERT" --format PEM
sudo /usr/bin/cp -fv ${DEV_CERT} ${HOME}/aspnet-$USER.crt
sudo /usr/bin/cp -fv ${DEV_CERT} /etc/pki/tls/certs/localhost.pem
sudo /usr/bin/cp -fv ${DEV_CERT} /etc/ssl/certs/localhost.pem
sudo /usr/bin/cp -fv ${DEV_CERT} /etc/pki/ca-trust/source/localhost.pem
sudo /usr/bin/cp -fv ${DEV_CERT} /usr/share/pki/ca-trust-source/anchors/localhost.pem
/usr/bin/cp -fv ${DEV_CERT} ~/.mozilla/certificates/localhost.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n localhost -i ${HOME}/aspnet-$USER.crt
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n localhost -i ${HOME}/aspnet-$USER.crt
sudo update-ca-trust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment