Missing certificate path with dot net core

I have the following configuration item with a dot net core service

                options.Listen(IPAddress.Loopback, 9010, listenOptions =>
                {
                    listenOptions.UseHttps("cert.pfx", "xxxx");
                });

It complains that the file is not found, however the file does exist in the output folder.

Any thoughts ?

It appears that Environment.CurrentDirectory points to the root service folder not the bin\debug… folder I was expecting.

Found this discussion

Issue is due to some ASP.NET constraint which breaks for console applications. Workaround is to use something like this to get the path rather than rely on Current directory to be the bin folder.

Path.GetDirectoryName(Assembly.GetEntryAssembly().Location

1 Like