简体   繁体   中英

C# Windows Service ,The request was aborted: Could not create SSL/TLS secure channel with SecurityProtocol

So We have windows service api that gets data then send to web using webclient the problem is we have this certain branch that sends error while other branches api are working fine except for this one branch that sends error:

"The request was aborted: Could not create SSL/TLS secure channel"

i have added

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

yet the error still occured , please help and thankyou

heres the code

I'm guessing you already followed the top voted here: The request was aborted: Could not create SSL/TLS secure channel

Try to extend you tls protocols like this, so that it can fallback to previous versions if the server does not support them:

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
               | SecurityProtocolType.Tls11
               | SecurityProtocolType.Tls12
               | SecurityProtocolType.Ssl3;

If it doesn't work still, try the answer by User:APW with extra troubleshooting steps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM