I am trying to run the application using IP address instead of localhost on https like https://192.1638.2.1:5001/index.html
.
What I have done:
- I have created a self-signed certificate using below power shell code.
New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\My" -dnsname "192.168.2.1" -NotAfter (Get-Date).AddYears(10) -FriendlyName "SS_192_168_2_1" -KeyUsageProperty All -KeyUsage CertSign, CRLSign, DigitalSignature
Thumbprint Subject
---------- -------
ABE394F15852C9389655F3EBC111FCE624D43479 CN=192.168.2.1
$mypwd = ConvertTo-SecureString -String "SS123" -Force -AsPlainText
Get-ChildItem -Path cert:\localMachine\my\ABE394F15852C9389655F3EBC111FCE624D43479 | Export-PfxCertificate -FilePath "D:\Certificates\SS_192_168_2_1.pfx" -Password $mypwd
Added
SS_192_168_2_1.pfx
to certificate store inTrusted Root Certificate Authority
ofCurrent User
. While adding this a popup came asking for password setup and have entered a new password and got saved warning popup.Configured .NET core web API app to use this file as server certificate.
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
webBuilder.ConfigureKestrel(options =>
{
options.ConfigureEndpointDefaults(listenOptions =>
{
// Loads the certificate (a must-have)
listenOptions.UseHttps(@"D:\Certificates\SS_192_168_2_1.pfx", "SS123");
});
options.ConfigureHttpsDefaults(o =>
{
o.ClientCertificateMode = ClientCertificateMode.NoCertificate;
});
});
});
}
Issue:
- Still the browser shows
Not Secure
and post man shows asSelf signed certificate
whereas localhost is showing Secure. What is that I am missing here??