简体   繁体   English

Java Bouncy Castle TLS 协议版本顺序?

[英]Java Bouncy Castle TLS Protocol version order?

I'm using the Java Bouncy Castle TLS library (bctls-jdk15to18-1.68.jar).我正在使用 Java Bouncy Castle TLS 库 (bctls-jdk15to18-1.68.jar)。 When I call SSLContext.getInstance , I specify "TLS" and the BCJSSE provider:当我调用SSLContext.getInstance时,我指定“TLS”和 BCJSSE 提供程序:

final SSLContext context    =   SSLContext.getInstance("TLS",BCJSSE);
                 context.init(kmf.getKeyManagers(), tmf.getTrustManagers(), keyStoreSalter);
logger.debug(Arrays.toString(context.getSupportedSSLParameters().getProtocols()));

When I query the SupportedSSLParameters of the context, it returns: [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3]当我查询上下文的 SupportedSSLParameters 时,它返回: [TLSv1.3, TLSv1.2, TLSv1.1, TLSv1, SSLv3]

As the client, are all of these versions communicated to the server, and the server chooses the highest that it supports?作为客户端,是否所有这些版本都与服务器通信,服务器选择它支持的最高版本?

If I denote a specific version SSLContext.getInstance("TLSv1.3",BCJSSE);如果我表示特定版本SSLContext.getInstance("TLSv1.3",BCJSSE); and the server does not support that version is an exception thrown?并且服务器不支持该版本是否抛出异常?

I'm trying to determine why you would ever specify a version in your call, if the negotiation will automagically determine the best match.如果协商会自动确定最佳匹配,我正在尝试确定您为什么会在通话中指定版本。

EDIT: Added so this is attached: Perfect test site for TLS/SSL编辑:添加所以附上:完美的 TLS/SSL 测试站点

As the client, are all of these versions communicated to the server, and the server chooses the highest that it supports?作为客户端,是否所有这些版本都与服务器通信,服务器选择它支持的最高版本?

The client simply tells which versions are supported (TLS 1.3 supported_versions extension) or announces the best it can do (TLS 1.2 and lower).客户端只需告知支持哪些版本(TLS 1.3 supported_versions扩展)或宣布它可以做到的最好的版本(TLS 1.2 和更低版本)。 The server then simply picks the highest protocol version which is supported by both client and server.然后服务器简单地选择客户端和服务器都支持的最高协议版本。

If I denote a specific version SSLContext.getInstance("TLSv1.3",BCJSSE);如果我表示特定版本 SSLContext.getInstance("TLSv1.3",BCJSSE); and the server does not support that version is an exception thrown?并且服务器不支持该版本是否抛出异常?

If there is no common protocol version supported by both client and server then the handshake will fail and an exception thrown.如果客户端和服务器不支持通用协议版本,则握手将失败并抛出异常。

I'm trying to determine why you would ever specify a version in your call, if the negotiation will automagically determine the best match.如果协商会自动确定最佳匹配,我正在尝试确定您为什么会在通话中指定版本。

This will usually only be done if there is a requirement to not support versions below a specific one, ie support only TLS 1.2 and higher.这通常仅在需要不支持特定版本以下的版本时才会这样做,即仅支持 TLS 1.2 和更高版本。 Since TLS 1.0 is considered too weak already in some situations, this can be a real-world requirement.由于 TLS 1.0 在某些情况下已经被认为太弱,因此这可能是现实世界的要求。

"Supported" in the context of the JSSE API means that it is supported by this JSSE implementation and thus COULD be enabled, but NOT that it is enabled by default. JSSE API 上下文中的“支持”表示此 JSSE 实现支持它,因此可以启用,但不是默认启用。 If you want to see the actual protocols enabled on a new SSLSocket or SSLEngine , call the getEnabledProtocols method on it.如果您想查看在新SSLSocketSSLEngine上启用的实际协议,请对其调用getEnabledProtocols方法。

You can then experiment with which of the "supported" protocols are actually auto-enabled depending on the algorithm you used to construct the SSLContext .然后,您可以根据用于构造SSLContext的算法来试验哪些“支持的”协议实际上是自动启用的。 Notably specifying just "TLS" will not automatically enable TLSv1.3 in v1.68 (since it's the first release to support TLSv1.3 and we are being cautious).值得注意的是,仅指定“TLS”不会在 v1.68 中自动启用 TLSv1.3(因为它是第一个支持 TLSv1.3 的版本,我们很谨慎)。 Also SSLv3 is never automatically enabled. SSLv3 也永远不会自动启用。

Regardless of how you created the SSLContext , the enabled protocols can then be modified either through SSLSocket/SSLEngine.setEnabledProtocols , or through SSLParameters.setProtocols .无论您如何创建SSLContext ,启用的协议都可以通过SSLSocket/SSLEngine.setEnabledProtocolsSSLParameters.setProtocols进行修改。

All of the ENABLED protocols are communicated to the server, and the server chooses the highest that it supports.所有启用的协议都与服务器通信,服务器选择它支持的最高协议。 (Roughly speaking; some servers may negotiate the cipher suite first, and then check for a suitable protocol version). (粗略地说;一些服务器可能会先协商密码套件,然后检查合适的协议版本)。

You should configure your socket with all the versions you want to support and just try one call.您应该使用您想要支持的所有版本配置您的套接字,然后尝试一个调用。 It is not advisable to try one version at a time since it may expose you to a downgrade attack .一次尝试一个版本是不可取的,因为它可能会使您受到降级攻击

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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