Certificates

⚠️ Important:
A certificate for stanging is already present on the DockerHub server at the following location:

ls /home/sysadmin/SmartFarming/Certificates/

Create a development certrificate for your local environment

ℹ️ Info: Openssl must be installed on your local machine. If it is not installed, try calling it from WSL (Windows Subsystem for Linux) or install it from here.

Try it from PowerShell...

cd into the Certificates folder:

cd C:\smartfarming_local_root_folder\Certificates

and run the following commands (openssl):

# create private key and cert
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout development_key.pem -out development_cert.pem -subj "/CN=localhost" -addext "subjectAltName = DNS:localhost,IP:127.0.0.1"
# create pfx format - combined bundle for Kestrel, IIS, Docker, etc.
openssl pkcs12 -export -out development_cert.pfx -inkey development_key.pem -in development_cert.pem -password pass:VerySecret!

These created files within the Certificats folder will then be used within docker-compose.yml for deployment purposes.

... or try it from WSL (Windows Subsystem for Linux)

cd into the Certificates folder:

cd /mnt/c/smartfarming_local_root_folder/Certificates

and run the following commands (openssl):

# create private key and cert
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout development_key.pem -out development_cert.pem -subj "/CN=localhost" -addext "subjectAltName = DNS:localhost,IP:127.0.0.1"
# create pfx format - combined bundle for Kestrel, IIS, Docker, etc.
openssl pkcs12 -export -out development_cert.pfx -inkey development_key.pem -in development_cert.pem -password pass:VerySecret!

These created files within the Certificats folder will then be used within docker-compose.yml for deployment purposes.

Alternative: Create an "ASP.NET HTTPS" development certificate

This command creates and exports a development HTTPS certificate that ASP.NET Core uses for local HTTPS browsing.

Run the following command to generate a local ASP.NET Core HTTPS development certificate (used for https://localhost when running apps locally):

dotnet dev-certs https -ep .\Certificates\devcert.pfx -p VerySecret!

This produces a file named devcert.pfx, which is a PKCS#12 certificate containing both the public and private keys, encrypted with the password VerySecret!.

This PFX file can also be used outside your local environment — for example, inside a docker container (see the config key ASPNETCORE_Kestrel__Certificates__Default__Path within docker-compose.yml) or on another machine such as the DockerHub server.