Reputation: 3574
Is there any way to forbid a re-handshake in Java's SSL libraries on client and server side?
I've already searched the Javadocs of SSLContext, SSLParameters, SSLSocket, SSLServerSocket and their according factories but have not found a solution.
Upvotes: 1
Views: 549
Reputation: 310915
To answer your real question, which appears in a comment to another answer, yes, you can continue sending data during a rehandshake.
Upvotes: 1
Reputation: 718836
I don't know of a (simple) good solution, but I have found a bad one.
It turns out in 2009, a security flaw was found in the SSL protocol that affected SSL renegotiation (or rehandshake). The Java team addressed it in two phases (as described here.). First phase was to disable renegotiation ... and this was done in Java 6 patch 19. The second phase was to implement the protocol changes for renegotiation specified in a new RFC.
So, one way to disable SSL renegotiation would be downgrade your JVM to Java 6 patch 19.
Frankly, I think this is a really bad idea:
However, if this digs you out of a really deep hole, you might consider it.
Well, I looked at the source code of SSLEngineImpl
(here), and I cannot see a straightforward solution based on that. Look for the kickstartHandshake
method.
There are a couple of properties that enable / disable unsafe forms of renegotiation (for compatibility), but there are no properties to turn it off entirely. And since the method that does all of the work is private
, I don't think you could disable the renegotiation functionality by overriding the methods in a subclass.
So that probably leaves you with copying the code, modifying it to disable renegotiation, changing the package names and creating an alternative "provider" the SSL engine.
And just to confuse things further ... there is another implementation of the SSL protocol in the SSLSocketImpl
class (here). I didn't try to figure out which of the two implementations is the one that you get "by default".
Upvotes: 2