Search code examples
linuxasp.net-coressl-certificatemanjaro

Manjaro / Arch Linux - How do I trust my AspNet Dev Certificate?


I use Manjaro for dotnet development and recently have been having serious problems with SSL.

When I run my web apps I get a warning saying The ASP.NET Core developer certificate is not trusted. For information about trusting the ASP.NET Core developer certificate, see https://aka.ms/aspnet/https-trust-dev-cert.

I've been through the link with a fine tooth comb - It's not very helpful to us Linux users and even less helpful to Manjaro / Arch.

This has led me round the houses somewhat trying to wrap my head around exactly what I need to do to actually trust this certificate - what do I run? where is it actually stored?

I've found a lot of information and most of it seems to be quite dated. I've got myself in a bit of a mess now - It's still not working and I've tried many things.

I extrapolated the commands below from an article on Github, but I'm not sure the storage locations are quite right.

# Start at home
cd ~

# Create cert
dotnet dev-certs https

# Export cert to current directory
dotnet dev-certs https -ep localhost.crt --format PEM

# Create the paths if necessary
cd /usr/share/ca-certificates
sudo mkdir trust-source
sudo chmod 755 trust-source
cd trust-source
sudo mkdir anchors
sudo chmod 755 anchors
cd ~

# Trust Chromium based browsers
sudo -E dotnet dev-certs https -ep /usr/share/ca-certificates/aspnet/https.crt --format PEM
sudo certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n localhost -i ./localhost.crt
sudo certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n localhost -i ./localhost.crt

# Trust wget
sudo cp localhost.crt /usr/share/ca-certificates/trust-source/anchors/aspnetcore-https-localhost.pem
sudo update-ca-trust extract

# Trust dotnet-to-dotnet
sudo cp localhost.crt /etc/ssl/certs/aspnetcore-https-localhost.pem

# Remove cert from current directory
rm localhost.crt

I'm almost at the point of giving up and going back to WIndows for work, which I really don't want to have to do as I find Linux far better for front-end development and I find Manjaro far better than Ubuntu generally, which would be my alternative switch over time.


Solution

  • Hope you have not given up yet.

    Go here: https://github.com/BorisWilhelms/create-dotnet-devcert

    Steps:

    • git clone [email protected]:BorisWilhelms/create-dotnet-devcert.git
    • cd create-dotnet-devcert
    • . ./scripts/arch-create-dotnet-devcert

    And you are done!