I am currently developing a Web Application that requires to retrieve data from an IDM system which in Dev Environment uses a Self-Signed certificate (I don't know the reason). It uses OAuth as Authorization method, so I am currently using .Net Core 3.1 OAuth libraries which throws a SSL Exception after successful redirection from the IDM. I was given the self-signed certificate (PFX file) from the IDM but I don't know where to add it.
public void ConfigureServices(IServiceCollection services)
{
//services.Configure<KestrelServerOptions>(pConfiguration.GetSection("Kestrel"));
services.AddControllers();
services.AddControllersWithViews();
services
.AddAuthentication(authenticationOptions => {
authenticationOptions.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
authenticationOptions.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
authenticationOptions.DefaultChallengeScheme = "the_scheme_challenge";
})
.AddCookie()
.AddOAuth(authenticationScheme: "the_scheme", configureOptions: oauthOptions => {
oauthOptions.ClientId = pConfiguration["the_scheme:ClientId"];
oauthOptions.ClientSecret = pConfiguration["the_scheme:ClientSecret"];
oauthOptions.CallbackPath = new PathString(pConfiguration["the_scheme:CallbackURL"]);
oauthOptions.AuthorizationEndpoint = "https://the.idm.dev/idm/oauth/authorize";
oauthOptions.TokenEndpoint = "https://the.idm.dev/idm/oauth/token";
oauthOptions.UserInformationEndpoint = "https://the.idm.dev/idm/oauth/userinfo";
oauthOptions.Scope.Add(pConfiguration["the_scheme:Scope"]);
oauthOptions.SaveTokens = true;
});
}
Any advice would be accepted, I don't want to write all the HTTP Requests and Logic from scratch with some insecure code (like allowing any certificate to be accepted).
I've tested the code against other OpenID providers and it worked.