- Open PowerShell as administrator
- Run the following command:
C:\Users\user01> New-SelfSignedCertificate -Subject “CN=OrgCert1234” -CertStoreLocation “cert:\LocalMachine\My”
Now, what we have to do is obtain the private key certificate file to be able to upload it to Azure:
- Press the windows key
- Type Manage Computer Certificates and press Enter
- Go to Personal (on the left), then Certificates
- Double-click on the certificate you created
- Go to Details
- Press the button “Copy to File …”
- Click Next
- Click on “Yes, export the private key”, then Next
- Click Next
- Click on Password, and enter a password (write down the password, we will need it)
- In Encryption, select TripleDESH-SHA1, click Next
- Select where you want to export your certificate, next and Finish
pfx Private Key Certificates will be created. Upload this file Azure.
Uploading the Certificate to Azure
To upload the newly created certificate we will do the following:
- Go to your Azure App Service
- Go to TLS / SSL settings
- Click on Private Key Certificates (.pfx)
- Click on Upload Certificate
- Select the pfx file you created
- Insert the password that we used in the previous section
- Click on Upload
If the upload is successful, you should see the certificate on the screen. If you click on it, you will see its details. We will need two of these fields, the Thumbprint and the Subject Name. Save both, because we will need them.
Permissions
We need to give Azure App Service permission to use the newly uploaded certificate. For that:
- Go to Configuration in the menu of your Azure App Service
- Click on New application setting
- In Name, put: WEBSITE_LOAD_CERTIFICATES
- In Value, put the Thumbprint that you copied from the previous section.
- Click Ok, and don’t forget to click Save
Name WEBSITE_LOAD_CERTIFICATES
Value xxxxxxxxx
Configuring the Project
Finally, we must configure our application to use the certificate. You can do this in the following way:
- In your Server project, go to appsettings.json
- Put the following code inside the IdentityServer section:
appsettings.json
"IdentityServer": {
"Clients": {
"MyProject01.Client": {
"Profile": "IdentityServerSPA"
}
},
"Key": {
"Type": "Store",
"StoreName": "My",
"StoreLocation": "CurrentUser",
"Name": "CN=OrgCert1234"
}
},
Comments