简体   繁体   English

连接服务 .net 核心的客户端证书

[英]Client certificate to connected service .net core

I have a .net core 2 API where i've connected a WCF service (which is an email sender);我有一个 .net core 2 API,我在其中连接了 WCF 服务(这是一个电子邮件发件人); The service is hosted on IIS with HTTPS and require SSL;该服务托管在带有 HTTPS 的 IIS 上并需要 SSL; I want to pass the client certificate from the api whenever i make the connection to the email service.每当我连接到电子邮件服务时,我都想从 api 传递客户端证书。 I think the only solution is to change the reference.cs file (which is not the best practice and i have no idea what should i change)我认为唯一的解决方案是更改reference.cs文件(这不是最佳做法,我不知道应该更改什么)

This is my startup.cs file;这是我的 startup.cs 文件; I made this because i want a dynamic url based on the environment我这样做是因为我想要一个基于环境的动态 url

   services.AddTransient<IEmailService, EmailServiceClient>((serviceProvider) =>
        {
            var configuration = serviceProvider.GetService<IConfiguration>();

            var url = configuration.GetValue<string>("EmailServiceUrl");

            return new EmailServiceClient(EmailServiceClient.EndpointConfiguration.WSHttpBinding_IEmailService, url);
        });

Any suggestion任何建议

I've added the client certificate to the ServiceClient after i instante it in the Startup.cs在 Startup.cs 中实例化后,我已将客户端证书添加到 ServiceClient

            client.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine,
                System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindByThumbprint, "thumbprint");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .Net Core 连接服务与 SSL 证书 - .Net Core Connected Service with SSL Certificate 无法使用Asp.net Core WCF连接的服务添加多个客户端证书 - Cannot add multiple client certificates with asp.net core wcf connected service 连接的服务 WCF 不工作 NET core 3.1 - Connected service WCF not work NET core 3.1 客户端证书HttpClient .Net Core Docker Linux - Client certificate HttpClient .Net Core Docker Linux 将客户端证书添加到 .NET Core HttpClient - Add client certificate to .NET Core HttpClient .NET Core ChannelFactory-将X509Certificate2设置为客户端证书 - .NET Core ChannelFactory - Set a X509Certificate2 as Client Certificate 我的 ASP.NET 核心应用服务 Web API 如何支持 AAD 承载令牌和客户端证书身份验证? - How can my ASP.NET Core App Service Web API support both AAD Bearer Token and Client Certificate Auth? .Net Core 2/SignalR:从控制器解析当前连接的 API 客户端 - .Net Core 2/SignalR: Resolving currently connected API client from a controller Asp.Net Core 连接服务 SOAP 方法始终 Null - Asp.Net Core Connected Service SOAP Method Always Null HttpClient不使用.NET Core在Windows上发送客户端证书 - HttpClient does not send client certificate on Windows using .NET Core
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM