[英]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.