don't check ssl certs 😬

This commit is contained in:
Muhammad Azeez 2021-01-17 12:14:40 +03:00
parent dac893275a
commit ecbba4c648
3 changed files with 17 additions and 2 deletions

View File

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System.Net;
namespace OidcSamples.AuthorizationServer namespace OidcSamples.AuthorizationServer
{ {
@ -23,6 +24,10 @@ namespace OidcSamples.AuthorizationServer
{ {
services.AddControllersWithViews(); services.AddControllersWithViews();
// Dirty Hack: Disable verifying SSL certificates 😬
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
services.AddCors(options => services.AddCors(options =>
{ {
options.AddPolicy(name: "Default", options.AddPolicy(name: "Default",

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.OpenIdConnect; using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -14,6 +14,7 @@ using Microsoft.Net.Http.Headers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OidcSamples.TaxApp namespace OidcSamples.TaxApp
@ -30,6 +31,10 @@ namespace OidcSamples.TaxApp
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// Dirty Hack: Disable verifying SSL certificates 😬
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
services.AddRazorPages(); services.AddRazorPages();
services.AddControllersWithViews(); services.AddControllersWithViews();

View File

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -16,6 +16,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IdentityModel.Tokens.Jwt; using System.IdentityModel.Tokens.Jwt;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OidcSamples.TrafficPoliceApi namespace OidcSamples.TrafficPoliceApi
@ -32,6 +33,10 @@ namespace OidcSamples.TrafficPoliceApi
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// Dirty Hack: Disable verifying SSL certificates 😬
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
JwtSecurityTokenHandler.DefaultInboundClaimTypeMap["sub"] = "sub"; JwtSecurityTokenHandler.DefaultInboundClaimTypeMap["sub"] = "sub";
services.AddCors(options => services.AddCors(options =>