X509Certificate2 certificate = new X509Certificate2(@"Certificate/certificate.p12", "password", X509KeyStorageFlags.MachineKeySet);
var handler = new HttpClientHandler();
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.SslProtocols = SslProtocols.Tls | SslProtocols.Tls12 | SslProtocols.Tls11;
handler.ClientCertificates.Add(certificate);
var client = new HttpClient(handler);
var request = new HttpRequestMessage
{
Method = method,
RequestUri = new Uri("endpoint" + url, UriKind.Absolute),
Content = content
};
var result = await client.SendAsync(request);
var responseStr = await result.Content.ReadAsStringAsync();
This method works in the local environment but when I publish this to the AWS ec2 env, I get this error A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
I have also added client certificate to the current user and local machine in ec2 using mmc.
Running OS in ec2 windows server 2019 Datacenter (Build 17763).
This issue is caused by ec2 instance server configuration. After i change security groups inbound and outbound rules to below settings it worked fine.
Inbound rule
Outbound rule