为旧的Grails站点(Grails 2.3)设置Java System.Property(为启用TLS1.1) [英] Setting Java System.Property (to Enable TLS1.1) for older grails site (Grails 2.3)

查看:144
本文介绍了为旧的Grails站点(Grails 2.3)设置Java System.Property(为启用TLS1.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个相当古老的Grails网站(2.3),它已经满足了我们的需求很长一段时间。服务器需要呼叫另一个服务以获取客户详细信息,该服务将很快只需要TLS 1.1或更高版本。我们的网站运行在Java 1.7上,它应该支持TLS 1.1和1.2,但需要明确启用它。我无法在grails站点中启用它。



主要是我尝试的是通过运行来启动grails

  grails -Dhttps.protocols = TLSv1.1 run-app 

根据此处的说明,并提示 here 。但是,当我尝试登录到其他站点时,套接字仍处于关闭状态:

 消息:连接重置
Line |方法
- >> 196 |请阅读java.net.SocketInputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 122 |请阅读''
| 82 | flushBuffer。 。 。 。 。 。在java.io.BufferedOutputStream
|中140 |刷新''
| 191 |冲洗。 。 。 。 。 。 。 。 。在org.apache.commons.httpclient.ChunkedOutputStream
|中99 |在com.ctc.wstx.io.UTF8Writer
|中刷新214 |冲洗。 。 。 。 。 。 。 。 。在com.ctc.wstx.sw.BufferingXmlWriter
|中311 |在com.ctc.wstx.sw.BaseStreamWriter
|中刷新50 |冲洗。 。 。 。 。 。 。 。 。 in org.apache.axiom.util.stax.wrapper.XMLStreamWriterWrapper
| 230 | flush in org.apache.axiom.om.impl.MTOMXMLStreamWriter
| 91 |序列化。 。 。 。 。 。 。在org.apache.axis2.databinding.ADBDataSource
|中638 | internalSerialize in org.apache.axiom.om.impl.llom.OMSourcedElementImpl
| 563 | serializeChildren。 。 。 in org.apache.axiom.om.impl.util.OMSerializerUtil
| 846 | org.apache.axiom.om.impl.llom.OMElementImpl中的internalSerialize
| 267 |序列化内部。 。 in org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl
| 229 | ''
|中的internalSerialize 188 | serializeAndConsume。 。 in org.apache.axiom.om.impl.llom.OMSerializableImpl
| 74 | writeTo in org.apache.axis2.transport.http.SOAPMessageFormatter
| 84 | writeRequest。 。 。 。 。 in org.apache.axis2.transport.http.AxisRequestEntity
| 499 | writeRequestBody在org.apache.commons.httpclient.methods.EntityEnclosingMethod
| 2114 | writeRequest。 。 。 。 。在org.apache.commons.httpclient.HttpMethodBase
|中1096 |在''
|中执行398 | executeWithRetry。 。 。在org.apache.commons.httpclient.HttpMethodDirector
|中171 |在''
|中执行方法397 | executeMethod。 。 。 。 。在org.apache.commons.httpclient.HttpClient
|中621 | executeMethod in org.apache.axis2.transport.http.AbstractHTTPSender
| 193 | sendViaPost。 。 。 。 。 。在org.apache.axis2.transport.http.HTTPSender
|中75 |发送''
| 404 | writeMessageWithCommons in org.apache.axis2.transport.http.CommonsHTTPTransportSender
| 231 |在''
|中调用443 |发送。 。 。 。 。 。 。 。 。在org.apache.axis2.engine.AxisEngine
|中406 |发送到org.apache.axis2.description.OutInAxisOperationClient
| 229 | executeImpl。 。 。 。 。 。在''
|中165 |在org.apache.axis2.client.OperationClient
|中执行3916 |登录 。 。 。 。 。 。 。 。 。在com.zuora.api.ZuoraServiceStub
|中51 | ___init___ in com.zuora.zortal.util.ZApi $$ EPbnSoym
| 48 | < INIT> 。 。 。 。 。 。 。 。在com.zuora.zortal.repository.ZuoraRepository
|中40 |登录saaseiportal.unauthorized.LoginController
| 195 | doFilter。 。 。 。 。 。 。在grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker。 。 。 。 。 。 。在java.util.concurrent.ThreadPoolExecutor
|中615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
^ 745 |中运行跑 。 。 。 。 。 。 。 。 。 。在java.lang.Thread中

我已经确认我的系统和系统的java支持TLS 1.1。我创建了一个示例Java客户端来直接连接到该网站。当我经常运行它时,它会得到类似的连接重置消息,但当我尝试使用时,它会得到有效的响应。 protocols = TLSv1.1 SampleHttpTest

我怀疑grails中的某处实际上是清除了我的设置。紧接在生成异常的登录调用之前,我向

添加了一个日志记录调用:

  System.out.println(System.getProperty( https.protocols)); 

它只记录一个空值。在我尝试登录之前立即设置该属性没有任何作用,可能是因为它在应用程序的生命中已经太迟了(某些工厂已经创建或者其他东西)。



我是实际上是Grails新手的一些东西,所以将应用升级到grails 2.5和java 8实际上是一个相当艰巨的前景。我希望有人能指出一些简单的东西:



这里是让grails在运行任何其他java代码之前设置系统属性的地方

这里是grails设置一堆默认设置的地方,你应该检查那些已经存在的值

这可能是需要用这些设置清除/修改的身份验证插件(或者其他)



预先感谢您的帮助!! 成为叉子模式。要将JVM参数传递给分叉的Java,您必须稍微更改 BuildConfig.groovy

  grails.project.fork = [
...
run:[maxMemory:1280,minMemory:128,debug:false,maxPerm:256,forkReserve:true,jvmArgs: ['-Dhttps.protocols = TLSv1.1']],
...
]

但它也可能是别的。


We have a rather ancient Grails site (2.3) that has been serving our needs for quite a while. The server needs to call out to another service for customer details, and that service will soon require TLS 1.1 or higher only. Our site is running on java 1.7, which should support TLS 1.1 and 1.2, but requires it to be enabled explicitly. I'm having trouble enabling it in the grails site.

Primarily what I've tried is to start grails by running

grails -Dhttps.protocols=TLSv1.1 run-app

based on the instructions here, and the hint here. But when I do, the socket is still closed when I try to login to the other site:

Message: Connection reset
    Line | Method
->>  196 | read                    in java.net.SocketInputStream
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    122 | read                    in     ''
|     82 | flushBuffer . . . . . . in java.io.BufferedOutputStream
|    140 | flush                   in     ''
|    191 | flush . . . . . . . . . in org.apache.commons.httpclient.ChunkedOutputStream
|     99 | flush                   in com.ctc.wstx.io.UTF8Writer
|    214 | flush . . . . . . . . . in com.ctc.wstx.sw.BufferingXmlWriter
|    311 | flush                   in com.ctc.wstx.sw.BaseStreamWriter
|     50 | flush . . . . . . . . . in org.apache.axiom.util.stax.wrapper.XMLStreamWriterWrapper
|    230 | flush                   in org.apache.axiom.om.impl.MTOMXMLStreamWriter
|     91 | serialize . . . . . . . in org.apache.axis2.databinding.ADBDataSource
|    638 | internalSerialize       in org.apache.axiom.om.impl.llom.OMSourcedElementImpl
|    563 | serializeChildren . . . in org.apache.axiom.om.impl.util.OMSerializerUtil
|    846 | internalSerialize       in org.apache.axiom.om.impl.llom.OMElementImpl
|    267 | serializeInternally . . in org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl
|    229 | internalSerialize       in     ''
|    188 | serializeAndConsume . . in org.apache.axiom.om.impl.llom.OMSerializableImpl
|     74 | writeTo                 in org.apache.axis2.transport.http.SOAPMessageFormatter
|     84 | writeRequest . . . . .  in org.apache.axis2.transport.http.AxisRequestEntity
|    499 | writeRequestBody        in org.apache.commons.httpclient.methods.EntityEnclosingMethod
|   2114 | writeRequest . . . . .  in org.apache.commons.httpclient.HttpMethodBase
|   1096 | execute                 in     ''
|    398 | executeWithRetry . . .  in org.apache.commons.httpclient.HttpMethodDirector
|    171 | executeMethod           in     ''
|    397 | executeMethod . . . . . in org.apache.commons.httpclient.HttpClient
|    621 | executeMethod           in org.apache.axis2.transport.http.AbstractHTTPSender
|    193 | sendViaPost . . . . . . in org.apache.axis2.transport.http.HTTPSender
|     75 | send                    in     ''
|    404 | writeMessageWithCommons in org.apache.axis2.transport.http.CommonsHTTPTransportSender
|    231 | invoke                  in     ''
|    443 | send . . . . . . . . .  in org.apache.axis2.engine.AxisEngine
|    406 | send                    in org.apache.axis2.description.OutInAxisOperationClient
|    229 | executeImpl . . . . . . in     ''
|    165 | execute                 in org.apache.axis2.client.OperationClient
|   3916 | login . . . . . . . . . in com.zuora.api.ZuoraServiceStub
|     51 | ___init___              in com.zuora.zortal.util.ZApi$$EPbnSoym
|     48 | <init> . . . . . . . .  in com.zuora.zortal.repository.ZuoraRepository
|     40 | login                   in saaseiportal.unauthorized.LoginController
|    195 | doFilter . . . . . . .  in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|     63 | doFilter                in grails.plugin.cache.web.filter.AbstractFilter
|   1145 | runWorker . . . . . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run                     in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . . . . . . . . in java.lang.Thread

I have confirmed that my system and system's java support TLS 1.1. I created an example java client to connect directly to the site. It gets a similar connection reset message when I run it regularly, but it gets a valid response when I try

java -Dhttps.protocols=TLSv1.1 SampleHttpTest

I suspect somewhere in grails is actually clearing out my setting. Immediately before the login call that generates the exception, I added a logging call to

System.out.println(System.getProperty("https.protocols"));

And it just logs a null. Setting that property immediately before I try to login has no effect, possibly because it's far too late in the application's life (some factory already created or something).

I'm actually something of a grails novice, so upgrading the app to grails 2.5 and java 8 is actually a rather daunting prospect. I'm hoping someone can point out something simple like:

"Here's where grails lets you set system properties before running any other java code" or "Here's where grails sets a bunch of default settings and you should check the values there already" or "It's probably the authentication plugin (or something) that needs to clear/fiddle with those settings"

Thanks in advance for any help!!

解决方案

It may be the fork mode. To pass a JVM argument to a forked Java you have to change the BuildConfig.groovy a bit:

grails.project.fork = [
    ...
    run    : [maxMemory: 1280, minMemory: 128, debug: false, maxPerm: 256, forkReserve: true, jvmArgs: ['-Dhttps.protocols=TLSv1.1']],
    ...
]

But it could be something else as well.

这篇关于为旧的Grails站点(Grails 2.3)设置Java System.Property(为启用TLS1.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆