У нас вы можете посмотреть бесплатно Resolving the Could not create SSL/TLS secure channel Error in C# Code или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Discover how to fix the common SSL/TLS secure channel error in your C# application when using PostAsync. --- This video is based on the question https://stackoverflow.com/q/76373457/ asked by the user 'Curious Developer' ( https://stackoverflow.com/u/3412113/ ) and on the answer https://stackoverflow.com/a/76642309/ provided by the user 'Curious Developer' ( https://stackoverflow.com/u/3412113/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: PostMan Token works but source code has error: The request was aborted: Could not create SSL/TLS secure channel during trace Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com. --- Understanding the SSL/TLS Issue in C# When working with APIs, particularly when obtaining tokens for authentication, you may encounter the frustrating error: "The request was aborted: Could not create SSL/TLS secure channel." This issue can arise during the development phase, particularly when transitioning from a live server to your local system. Here, we will explore why this happens and how to effectively resolve it. The Problem In this specific case, the error occurs while trying to retrieve a token using the PostAsync method in C# . The code works perfectly on a live server but breaks down when executed in a test environment on your local machine. The primary question is: Why does Postman request work without issues while your C# code fails? Why the Error Occurs The error is largely related to the security protocols being used for SSL/TLS connections. If your local environment does not support the necessary SSL/TLS version set by the server, then the request cannot be established, resulting in the mentioned error. Key Reasons Include: The server may require TLS 1.2, while the local application defaults to an older version. Inconsistent security configurations between your local development setup and the production server. Solution: Enforcing the Correct Security Protocols The good news is that this issue can typically be resolved by explicitly setting the desired SSL/TLS security protocols in your C# application. Here’s how to do this step by step: Step 1: Modify the Source Code You need to add the following lines to your code to enforce the TLS protocol: [[See Video to Reveal this Text or Code Snippet]] Step 2: Implementing in Your Code To ensure that these settings only apply during testing, encapsulate them in a conditional block. Here’s how you can do that: [[See Video to Reveal this Text or Code Snippet]] Step 3: Re-run Your Application Now that you have updated your code, re-run your application in the local environment. The error should be resolved, and you should be able to obtain the token successfully. Summary To summarize, the "Could not create SSL/TLS secure channel" error arises due to discrepancies in the SSL/TLS protocols supported in different environments. By enforcing TLS 1.2 in your local testing code, you can ensure compatibility and eliminate this irritating error. If you continue to face issues even after these adjustments, consider reviewing other aspects like firewall settings or network configurations that might impede SSL/TLS connections. Implementing these fixes can save you a significant amount of time and frustration, allowing you to focus on developing your application rather than troubleshooting connection errors. Happy coding!