如何在.net 4.0下安裝TLS1.2的支持


 原始出處:www.cnblogs.com/Charltsing/p/Net4TLS12.html

最近提交請求發生錯誤:不支持請求的協議,研究了一下TLS1.2,發現這玩意的支持和.Net環境的版本有關

 

//SecurityProtocolType.Tls1.0=0xC0; SecurityProtocolType.Tls1.1=0x300; SecurityProtocolType.Tls1.2=0xC00;
//.net 4.0/4.5默認值:SecurityProtocolType.Tls | SecurityProtocolType.Ssl3
//.net 4.6/4.7默認值:SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12
//https://support.microsoft.com/en-us/help/3069494/cannot-connect-to-a-server-by-using-the-servicepointmanager-or-sslstre
//SCH_USE_STRONG_CRYPTO 此標志將在.NET Framework 4.6中自動使用
//https://support.microsoft.com/en-us/help/3154518/support-for-tls-system-default-versions-included-in-the-net-framework 在Win7Sp1和.Net 3.5.1中,支持TLS1.2
ServicePointManager.SecurityProtocol &= ~SecurityProtocolType.Ssl3; //關閉ssl3
ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0x300 | (SecurityProtocolType)0xc00; //增加1.1和1.2支持
//TLS1.2的結論是這樣的:
//1、安裝.Net3.5.1需要打個補丁,然后增加TLS1.2枚舉
//2、安裝.Net 4.0需要修改注冊表,然后增加TLS1.2枚舉
//3、安裝.Net4.5之后,還需要增加TLS1.2枚舉
//4、安裝.Net4.6.1之后,默認支持TLS1.2

 

.net4下的注冊表修改,將以下內容存為reg,雙擊導入 ;代碼中加入:ServicePointManager.SecurityProtocol = (SecurityProtocolType)0xC00;

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001

 

 
 
 
標簽: TLS1.2
0
0
 
 
 
« 上一篇: Outlook插件開發(非VSTO),歡迎交流
» 下一篇: ThinkPad T400 鍵帽下面的X支架的安裝方法

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM