伙计们,我希望我遗漏了一些明显的东西,并且我希望有人能够提供一些线索。我正在尝试让 TLSv1.2 在 SSL + NIO 上下文中运行(使用Android异步 https://github.com/koush/AndroidAsync库),所以我尝试通过 SSLEngine 启用它。我可以运行这样的代码:
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
String[] protocols = sslContext.getSupportedSSLParameters().getProtocols();
for (String protocol : protocols) {
Timber.d("Context supported protocol: " + protocol);
}
SSLEngine engine = sslContext.createSSLEngine();
String[] supportedProtocols = engine.getSupportedProtocols();
for (String protocol : supportedProtocols) {
Timber.d("Engine supported protocol: " + protocol);
}
我最终在 logcat 上看到了这个:
06-22 21:56:27.715 1117-1117/? D/XXX﹕ Context supported protocol: SSLv3
06-22 21:56:27.715 1117-1117/? D/XXX﹕ Context supported protocol: TLSv1
06-22 21:56:27.725 1117-1117/? D/XXX﹕ Context supported protocol: TLSv1.1
06-22 21:56:27.725 1117-1117/? D/XXX﹕ Context supported protocol: TLSv1.2
06-22 21:56:27.735 1117-1117/? D/XXX﹕ Engine supported protocol: TLSv1
06-22 21:56:27.745 1117-1117/? D/XXX﹕ Engine supported protocol: SSLv3
当然如果我尝试engine.setEnabledProtocols(new String[] { "TLSv1.2" })
我收到 IllegalArgumentException“不支持协议 TLSv1.2”。
我可以看到上下文声称支持 TLSv1.2,但是我从该上下文创建的引擎却不支持?这里发生了什么?顺便说一句,如果我在上面第一行中使用“TLS”而不是“TLSv1.2”,则这些都不会改变。
我想这可能与这个问题 https://code.google.com/p/android/issues/detail?id=61085,我读过这个(尚未回答)问题 https://stackoverflow.com/questions/20573215/how-do-you-use-tlsv1-2-on-kitkat-was-where-is-openssl-1-0-1-in-the-android-19 and 像这样的文章 http://blog.dev001.net/post/67082904181/android-using-sni-and-tlsv1-2-with-apache-httpclient,但它们似乎并不太切中要害——我见过的所有解决方案似乎都依赖于 SSLSocket 而不是 SSLEngine。
非常感谢您可以放弃的任何知识。
更新时间:2014 年 6 月 23 日 10AMDT
所以我发现SSLEngine.setSSLParameters
,我希望它能让我传递我从中获得的 SSLParametersSSLContext.getSupportedSSLParameters()
,但是当我调用它时,我得到一个异常,声称不支持密码套件,因此看起来 setSSLParameters() 所做的事情与 setEnabledCipherSuites() 所做的相同,并且引擎已经处于不支持的状态无法识别受支持的 TLS 1.2 协议/套件。