1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-11 22:52:15 -05:00

Remove X509ChainCustomization activation code

This commit is contained in:
Justin Baur 2025-05-06 13:39:10 -04:00
parent 05e58cb9e4
commit b1efa88c6d
No known key found for this signature in database
11 changed files with 1 additions and 56 deletions

View File

@ -89,9 +89,6 @@ public class Startup
services.AddScimGroupQueries(); services.AddScimGroupQueries();
services.AddScimUserQueries(); services.AddScimUserQueries();
services.AddScimUserCommands(); services.AddScimUserCommands();
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -86,9 +86,6 @@ public class Startup
// TODO: Remove when OrganizationUser methods are moved out of OrganizationService, this noop dependency should // TODO: Remove when OrganizationUser methods are moved out of OrganizationService, this noop dependency should
// TODO: no longer be required - see PM-1880 // TODO: no longer be required - see PM-1880
services.AddScoped<IServiceAccountRepository, NoopServiceAccountRepository>(); services.AddScoped<IServiceAccountRepository, NoopServiceAccountRepository>();
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -129,9 +129,6 @@ public class Startup
services.AddHostedService<HostedServices.AzureQueueMailHostedService>(); services.AddHostedService<HostedServices.AzureQueueMailHostedService>();
} }
} }
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -234,9 +234,6 @@ public class Startup
{ {
services.AddSingleton<ISlackService, NoopSlackService>(); services.AddSingleton<ISlackService, NoopSlackService>();
} }
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -131,9 +131,6 @@ public class Startup
// Swagger // Swagger
services.AddEndpointsApiExplorer(); services.AddEndpointsApiExplorer();
services.AddSwaggerGen(); services.AddSwaggerGen();
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -152,9 +152,6 @@ public class Startup
globalSettings, globalSettings,
globalSettings.EventLogging.RabbitMq.WebhookQueueName)); globalSettings.EventLogging.RabbitMq.WebhookQueueName));
} }
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -82,9 +82,6 @@ public class Startup
globalSettings.EventLogging.AzureServiceBus.WebhookSubscriptionName)); globalSettings.EventLogging.AzureServiceBus.WebhookSubscriptionName));
} }
services.AddHostedService<AzureQueueHostedService>(); services.AddHostedService<AzureQueueHostedService>();
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -47,9 +47,6 @@ public class Startup
// Mvc // Mvc
services.AddMvc(); services.AddMvc();
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -163,9 +163,6 @@ public class Startup
{ {
client.BaseAddress = new Uri(globalSettings.BaseServiceUri.InternalSso); client.BaseAddress = new Uri(globalSettings.BaseServiceUri.InternalSso);
}); });
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -76,9 +76,6 @@ public class Startup
services.AddHostedService<AzureQueueHostedService>(); services.AddHostedService<AzureQueueHostedService>();
} }
} }
// This should be registered last because it customizes the primary http message handler and we want it to win.
services.AddX509ChainCustomization();
} }
public void Configure( public void Configure(

View File

@ -1,11 +1,7 @@
using System.Globalization; using System.Globalization;
using System.Net.Http.Json; using System.Net.Http.Json;
using Bit.Core.Settings;
using Bit.Migrator; using Bit.Migrator;
using Bit.Setup.Enums; using Bit.Setup.Enums;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Bit.Setup; namespace Bit.Setup;
@ -289,29 +285,8 @@ public class Program
url = $"{installationUrl}/installations/"; url = $"{installationUrl}/installations/";
} }
var config = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string>
{
// Setup uses a different default location for the location of the CA certificates.
["X509ChainOptions:AdditionalCustomTrustCertificatesDirectory"] = "/bitwarden/ca-certificates",
})
// Still allow customization through environment variables though
.AddEnvironmentVariables()
.Build();
// We need to get an HttpClient that has been configured with custom trust certificates. var response = new HttpClient().GetAsync(url + _context.Install.InstallationId).GetAwaiter().GetResult();
var httpClient = new ServiceCollection()
.AddX509ChainCustomization()
.AddSingleton<IConfiguration>(config)
// Setup is always ran for self hosted, so it's fine to hard code this to true and allow chain customization
.AddSingleton(new GlobalSettings { SelfHosted = true })
.AddLogging()
.AddSingleton<IHostEnvironment>(new SetupHostEnvironment())
.BuildServiceProvider()
.GetRequiredService<IHttpClientFactory>()
.CreateClient();
var response = httpClient.GetAsync(url + _context.Install.InstallationId).GetAwaiter().GetResult();
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {