<ItemGroup>
<None Update="mydomain.pfx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
This addition will cause the PFX to be coped to your output directory. After adding this to your csproj, add the following section to your appsettings.json file to use the exported certificate:
"Kestrel": {
"Endpoints": {
"HttpsInlineCertFile": {
"Url": "https://test.mydomain.com",
"Certificate": {
"Path": "mydomain.pfx",
"Password": "mypfxpassword"
}
}
}
}
Poof, you're secure.