本文主要是介绍ATS的诊断工具:测试iOS使用的HTTPS地址是否符合ATS的规则,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
HTTPS适配完成后,可以先使用/usr/bin/nscurl
(OS X v10.11及以上系统支持)工具模拟进行ATS网络连接状况诊断,命令如下:
/usr/bin/nscurl --ats-diagnostics [--verbose] URL
连接指定URL时,
--ats-diagnostics
参数的设定,会模拟ATS属性的不同配置场景(NSAllowsArbitraryLoads、NSExceptionMinimumTLSVersion、NSExceptionRequiresForwardSecrecy和NSExceptionAllowsInsecureHTTPLoads的不同组合)进行连接;--verbose
指定时,可显示ATS不同配置场景的详细信息。
下面以网易云捕官网来测试验证:
/usr/bin/nscurl --ats-diagnostics --verbose https://crash.163.com
结果如下:
Starting ATS DiagnosticsConfiguring ATS Info.plist keys and displaying the result of HTTPS loads to https://crash.163.com.
A test will "PASS" if URLSession:task:didCompleteWithError: returns a nil error.
================================================================================Default ATS Secure Connection
---
ATS Default Connection
ATS Dictionary:
{
}
Result : PASS
---================================================================================Allowing Arbitrary Loads---
Allow All Loads
ATS Dictionary:
{NSAllowsArbitraryLoads = true;
}
Result : PASS
---================================================================================Configuring TLS exceptions for crash.163.com---
TLSv1.2
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionMinimumTLSVersion = "TLSv1.2";};};
}
Result : PASS
------
TLSv1.1
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionMinimumTLSVersion = "TLSv1.1";};};
}
Result : PASS
------
TLSv1.0
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionMinimumTLSVersion = "TLSv1.0";};};
}
Result : PASS
---================================================================================Configuring PFS exceptions for crash.163.com---
Disabling Perfect Forward Secrecy
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
---================================================================================Configuring PFS exceptions and allowing insecure HTTP for crash.163.com---
Disabling Perfect Forward Secrecy and Allowing Insecure HTTP
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionAllowsInsecureHTTPLoads = true;NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
---================================================================================Configuring TLS exceptions with PFS disabled for crash.163.com---
TLSv1.2 with PFS disabled
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionMinimumTLSVersion = "TLSv1.2";NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
------
TLSv1.1 with PFS disabled
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionMinimumTLSVersion = "TLSv1.1";NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
------
TLSv1.0 with PFS disabled
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionMinimumTLSVersion = "TLSv1.0";NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
---================================================================================Configuring TLS exceptions with PFS disabled and insecure HTTP allowed for crash.163.com---
TLSv1.2 with PFS disabled and insecure HTTP allowed
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionAllowsInsecureHTTPLoads = true;NSExceptionMinimumTLSVersion = "TLSv1.2";NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
------
TLSv1.1 with PFS disabled and insecure HTTP allowed
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionAllowsInsecureHTTPLoads = true;NSExceptionMinimumTLSVersion = "TLSv1.1";NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
------
TLSv1.0 with PFS disabled and insecure HTTP allowed
ATS Dictionary:
{NSExceptionDomains = {"crash.163.com" = {NSExceptionAllowsInsecureHTTPLoads = true;NSExceptionMinimumTLSVersion = "TLSv1.0";NSExceptionRequiresForwardSecrecy = false;};};
}
Result : PASS
---================================================================================
参考:
1. 苹果ATS(强制HTTPS)审核新政解码
这篇关于ATS的诊断工具:测试iOS使用的HTTPS地址是否符合ATS的规则的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!