title: Setting Java System.Property (to Enable TLS1.1) for older grails site (Grails 2.3)
body: <p>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.</p>
  
  <p>Primarily what I've tried is to start grails by running</p>
  
  <pre><code>grails -Dhttps.protocols=TLSv1.1 run-app
  </code></pre>
  
  <p>based on the instructions <a href="https://blogs.oracle.com/java-platform-group/entry/diagnosing_tls_ssl_and_https" rel="nofollow">here</a>, and the hint <a href="http://www.tothenew.com/blog/setting-system-property-from-command-line-in-grails/" rel="nofollow">here</a>. But when I do, the socket is still closed when I try to login to the other site:</p>
  
  <pre><code>Message: Connection reset
      Line | Method
  -&gt;&gt;  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 | &lt;init&gt; . . . . . . . .  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
  </code></pre>
  
  <p>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</p>
  
  <pre><code>java -Dhttps.protocols=TLSv1.1 SampleHttpTest
  </code></pre>
  
  <p>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 </p>
  
  <pre><code>System.out.println(System.getProperty("https.protocols"));
  </code></pre>
  
  <p>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).</p>
  
  <p>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:</p>
  
  <p>"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"</p>
  
  <p>Thanks in advance for any help!!</p>