-
Notifications
You must be signed in to change notification settings - Fork 102
Double initialization of SSLSession in GelfTCPSSLSender #181
Comments
Thanks for reporting an issue.
The call to logstash-gelf/src/main/java/biz/paluch/logging/gelf/intern/sender/GelfTCPSender.java Lines 100 to 105 in a8d749e
I'm not exactly sure, I'd suspect rather concurrent access to |
loop hole in overridden connect call in GelfTCPSSLSender, it recreates Any way both solutions work, you should choose which one to use =) |
Thanks for the hint. It makes sense now. The double checked lock isn't properly implemented for SSL because two threads can sequentially access Do you want to adjust your PR to move the initialization of |
Move initialization of sslEngine after connect happened
I don't understand your point, but moved initialization under if(super.connect(...)). I just want to make it clear.
|
remove redundant check
Thanks a lot.
You basically explained the flow. What I wanted to express is that in point 3., we have synchronization but what also happens is, that two threads get to the The second thread then continues with the |
In my first implementation second thread will be aware about connection was established because of isConnected check in the beginning of |
But I agree with moving initialization of sslEngine field after connect establishing, because it makes more sense. |
All calls to |
We now initialize the SSL Engine after the TCP connect succeeded. This change prevents concurrent connects from double initialization of the SSL Engine. It also defers resource creation to a time where we know that the TCP connect was successful. Original pull request: #182.
That's fixed via #182 now. Thanks a lot. |
Okay, thank you. |
Hi,
I think we have a problem in method connect() of GelfTCPSSLSender class
logstash-gelf/src/main/java/biz/paluch/logging/gelf/intern/sender/GelfTCPSSLSender.java
Lines 55 to 65 in 7553c8e
As you can see, you initialize
sslEngine
andsslSession
fields right away, afterconnect
method is done, we will have channel withsslEngine
.In multithreaded environment if two threads will call
sendMessage
method at the same time, one will initialise channel andsslSession
, and second will recreatesslEngine
andsslSession
.This leads us to situation like
javax.net.ssl.SSLException: Received fatal alert: ...
on client side,and
javax.crypto.BadPaddingException: ciphertext sanity check failed
on server sideMake sure that:
The text was updated successfully, but these errors were encountered: