简体   繁体   English

如何在groovy应用程序中升级http协议TLS1.2

[英]How to upgrade http protocol TLS1.2 in groovy application

I have groovy on grails 2.5.0 application where i want to set TLS1.2 as its using old TLS version. 我在grails 2.5.0应用程序上有一个groovy,我想将TLS1.2设置为使用旧的TLS版本。 below code i have set in bootstrap.groovy but seems its not working, any help appreciated. 下面的代码我已经在bootstrap.groovy中设置,但似乎它不起作用,任何帮助赞赏。

 def init = { servletContext ->

    System.setProperty("com.ibm.jsse2.overrideDefaultProtocol","TLSv12")
    System.setProperty("https.protocols","TLSv1.2")
    println "protocol in bootstrap = "+System.getProperty("https.protocols")
 }

But not able to see anything in println statement. 但是无法在println语句中看到任何内容。

First of all, not all jvm versions support TLS version 1.2. 首先,并非所有jvm版本都支持TLS 1.2版。 If you are using an oracle jvm, it needs to be a java 1.6.0.121 or later if on java 1.6, java 1.7.95 or later if on java 1.7 or any higher version of the jvm (ie java 8, java 9 etc). 如果你使用的是oracle jvm,它需要是java 1.6.0.121或更高版本,如果在java 1.6,java 1.7.95或更高版本,如果在java 1.7 更高版本的jvm(即java 8,java 9等) 。

Assuming that has been taken care of, you need to set the system property: 假设已经处理好了,您需要设置系统属性:

System.properties['jdk.tls.client.protocols'] = 'TLSv1.2'

It seems from reading the docs that the https.protocols setting should also work, but I know from configuring a large number server jvms using jdk.tls.client.protocols that it works. 通过阅读文档似乎https.protocols设置也应该工作,但我知道使用jdk.tls.client.protocols配置大量服务器jvms它可以工作。 Note that this is to make the server jvms use TLSv1.2 when making requests to the internet, ie when they are acting as clients. 请注意,这是为了使服务器jvms在向Internet发出请求时使用TLSv1.2,即当它们充当客户端时。 So we are here talking about configuring the client side of the request. 所以我们在这里讨论配置请求的客户端。 I'm assuming the server side needs to be configured differently. 我假设服务器端需要以不同方式配置。

Also, in your code, the statement: 此外,在您的代码中,声明:

println "protocol in bootstrap = "+System.getProperty("https.protocols")

is probably interpreted as 可能被解释为

println("protocol in bootstrap = ")+System.getProperty("https.protocols")

which translates to: 这意味着:

null+System.getProperty("https.protocols")

since println returns null. 因为println返回null。 This will print protocol in bootstrap = but not the system property. 这将protocol in bootstrap =打印protocol in bootstrap =但不是系统属性。

Try explicit parens instead: 尝试明确的parens:

println("protocol in bootstrap = "+System.getProperty("https.protocols"))

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

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