harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerald Jerome <gerald.jer...@verizonbusiness.com>
Subject RE: [classlib][xnet] Problem using SSLSocketImpl behind load balancer
Date Fri, 13 Apr 2007 16:44:31 GMT
Hi Leo, my project, which uses the Sun JDK not Apache Harmony's (sorry),
only uses the x-net and luni libraries for SSL communication - the rest of
the code uses only the Sun libraries.  I removed InetAddress from the
deployed luni jar (and all InetAddress$* classes as well).  My code still
functions and can communicate using SSL (TLS actually) .  My understanding
based on when I worked with other Harmony developers to get the handshake
working correctly is that SSLSocketImpl uses SSLEngine and is not subclassed
from Socket.  So my opinion is that setting networkaddress.cache or the
negative cache will have no effect.


Gerald Jerome

Vnet 262-2375



From: Leo Li [mailto:liyilei1979@gmail.com] 
Sent: Thursday, April 12, 2007 7:58 PM
To: dev@harmony.apache.org
Subject: Re: [classlib][xnet] Problem using SSLSocketImpl behind load


Hi, Gerald:

     The harmony build system adopts an incremental compiling, thus if the
InetAddress is removed, the build will still succeed since it regards that
no new/modification has occurred. Actually the deploy still contains the
InetAddress class if you look at the luni.jar built from it. But if you
clean the system, build system will complain about compiling errors. The
class is needed by several core classes, such as socket.

     So if you do not need the DNS caching, the solution is simple: Just
remove the caching mechanism in the InetAddress class.

     If you would like, you can try the patch in attachment, which can be
applied on the luni module at revision 528316. (It is just a customization
on classlib for your case, not for Harmony classlib itself.)

     Besides, you can also remove the return NagativeCache if necessary in
your case.


On 4/13/07, Gerald Jerome <gerald.jerome@verizonbusiness.com> wrote: 

Hi Leo, the first two clarifications appear correct, but I'm not sure DNS
caching is important as all our connections are created up front when the 
app starts and held in a pool (vector) - the Broker servers up connections
out of a connection pool as they are requested.  If a connection is unusable
say when the host fails or is taken down, the app attempts to recreate 
another SSLSocket connection.  It has been tested and found to be reasonably
fault tolerant, except we have this problem in production where a load
balancing or redirector exists between the client(s) and hosts. 
Interestingly, I deleted the InetAddress class from the luni library and
noticed no compilation errors and the app connects and is able to
communicate just fine.  So it appears either the caching never takes place 
or only if InetAddress is available, I don't know.


Gerald Jerome

-----Original Message-----
From: Leo Li [mailto:liyilei1979@gmail.com ]
Sent: Tuesday, April 10, 2007 11:05 PM
To: dev@harmony.apache.org
Subject: Re: [classlib][xnet] Problem using SSLSocketImpl behind load

Hi, Gerald: 
   First I would like to clarify your problem:
   1. We want to exchange the request to a new server seamlessly according
to workload balancing.
   2. The behavior of DNS caching prevent us from that.
   3. You would like to get the support from classlib, that is to enjoy the 
DNS caching as well as the response to server switching.

   Since Harmony would like to be a compatible classlib with RI's, we have
to comply with RI's behavior with RI's.
   But it is possible to customize harmony's classlib if you conform with 
apache license. So my suggestion is here:
   (1) Expose the method which clears the DNS cache in InetAddress to
public.(If you would like to maintain the interface of java public API, wrap
it in an implementation class and expose it as public.) 
   (2) On the socket side, if you use your socket implementation, in the
connection method, if the connection fails, clear the DNS cache by the
method exposed before and retry it.
   If you are interested, I think, we might talk about it in detail. 

On 4/11/07, Tim Ellison <t.p.ellison@gmail.com> wrote:
> Gerald Jerome wrote:
> > Hello, we are using the Apache Harmony SSLSocket classes to solve a 
> problem
> > we were having with SSL renegotiation.  However, recently our production
> > admin noticed that our SSL client was not automatically failing over to
> a
> > secondary machine that exists behind a load balancer or redistributor in

> > cases where a server goes down (either unexpectedly or for
> maintenance).  We
> > are using the Sun JVM and not the Apache Harmony version.  He mentions
> the
> > following: 
> That sounds like an interesting combination of code, and not something
> that I expect can be easily reproduced by the Harmony developers, so
> take the following information only as guidance -- I don't know what you 
> are actually running with...
> > Our investigation found that once Java based clients (both standalone
> > applications, and servlets) have performed the first network access (i.e
> . 
> > urlconnection, parsing of xml document with external references, etc)
> they
> > cache DNS settings, so any subsequent client request will use its old
> > information even if the real DNS settings have changed. 
> >
> > To reset everything, you have to restart the client application since
> the
> > default JVM setting is to cache forever.
> >
> > The InetAddress class has a cache to store successful as well as 
> > unsuccessful host name resolutions. The positive caching is there to
> guard
> > against DNS spoofing attacks.
> Correct, the scenario you describe is almost exactly as described here: 
> http://www.rgagnon.com/javadetails/java-0445.html
> > He goes on to discuss how the caching can be disabled.  I know your
> > SSLSocket implementation uses SSLEngine and does low-level socket based 
> > communication so I did not think his analysis may fit our situation.
> > Furthermore, I am not convinced that we are having this problem but our
> > development and test environments do not have a distributor/load 
> balancer in
> > front of the actual host machines.
> Hmm, this could really be a shot in the dark then!
> > I know in production we are configured
> > to connect to the distributor, not one of the actual hosts.  I am 
> wondering
> > if you were aware of any caching of DNS information that may be going on
> > inside the SSLSocket class and dependant code that we are using
> using?  I
> > could not find any references to the InetAddress class mentioned above 
> in
> > any of the Harmony source I have.
> If you have the luni.jar then you should have the java.net.InetAddress
> class (and java.net.NegativeCache class).  They will honour the
> networkaddress.cache.ttl and networkaddress.cache.negative.ttl properties.
> > The x-net.jar file that we are using has
> > a last modified date of October 28, 2006 8:27:58 PM. The last modified 
> date
> > of luni.jar is the same.  These are the only two Apache Harmony
> libraries we
> > are using.
> Those sound quite old now, although I don't recall significant
> development in x-net since then.
> > Any information you have pertaining to this problem is greatly
> > appreciated
> Maybe somebody else will have some insight, but it is really hard to 
> advise on a problem you are not sure you are having on a runtime
> codebase we don't know.
> Regards,
> Tim

Leo Li
China Software Development Lab, IBM 

Leo Li
China Software Development Lab, IBM 

  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message