Skip to content

Commit 0fd5c89

Browse files
committed
Also tone down SSL handshake exception log in TCP server and client
1 parent 619cb99 commit 0fd5c89

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

src/aleph/http/client.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
(s/put! response-stream ex)
109109

110110
;; when SSL handshake failed
111-
(http/ssl-handshake-error? ex)
111+
(netty/ssl-handshake-error? ex)
112112
(let [^Throwable handshake-error (.getCause ^Throwable ex)]
113113
(s/put! response-stream handshake-error))
114114

src/aleph/http/core.clj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
ByteBuf]
2424
[java.nio
2525
ByteBuffer]
26-
[io.netty.handler.codec DecoderException]
2726
[io.netty.handler.codec.http
2827
DefaultHttpRequest DefaultLastHttpContent
2928
DefaultHttpResponse DefaultFullHttpRequest
@@ -62,8 +61,7 @@
6261
ConcurrentLinkedQueue
6362
TimeUnit]
6463
[java.util.concurrent.atomic
65-
AtomicBoolean]
66-
[javax.net.ssl SSLHandshakeException]))
64+
AtomicBoolean]))
6765

6866
(def non-standard-keys
6967
(let [ks ["Content-MD5"
@@ -684,7 +682,3 @@
684682
(when (and (identical? ::ping-timeout v)
685683
(.isOpen ^Channel (.channel ctx)))
686684
(netty/close ctx))))))))
687-
688-
(defn ssl-handshake-error? [^Throwable ex]
689-
(and (instance? DecoderException ex)
690-
(instance? SSLHandshakeException (.getCause ex))))

src/aleph/http/server.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
(defn exception-handler [ctx ex]
212212
(cond
213213
;; do not need to log an entire stack trace when SSL handshake failed
214-
(http/ssl-handshake-error? ex)
214+
(netty/ssl-handshake-error? ex)
215215
(log/warn "SSL handshake failure:"
216216
(.getMessage ^Throwable (.getCause ^Throwable ex)))
217217

src/aleph/netty.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
SslContext
3838
SslContextBuilder
3939
SslHandler]
40+
[io.netty.handler.codec DecoderException]
4041
[io.netty.handler.ssl.util
4142
SelfSignedCertificate InsecureTrustManagerFactory]
4243
[io.netty.resolver
@@ -76,7 +77,8 @@
7677
LoggingHandler
7778
LogLevel]
7879
[java.security.cert X509Certificate]
79-
[java.security PrivateKey]))
80+
[java.security PrivateKey]
81+
[javax.net.ssl SSLHandshakeException]))
8082

8183
;;;
8284

@@ -789,6 +791,11 @@
789791
^SslHandler (.get SslHandler)
790792
.engine
791793
.getSession))
794+
795+
(defn ssl-handshake-error? [^Throwable ex]
796+
(and (instance? DecoderException ex)
797+
(instance? SSLHandshakeException (.getCause ex))))
798+
792799
;;;
793800

794801
(defprotocol AlephServer

src/aleph/tcp.clj

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@
3030

3131
:exception-caught
3232
([_ ctx ex]
33-
(when-not (instance? IOException ex)
34-
(log/warn ex "error in TCP server")))
33+
(cond
34+
;; do not need to log an entire stack trace when SSL handshake failed
35+
(netty/ssl-handshake-error? ex)
36+
(log/warn "SSL handshake failure:"
37+
(.getMessage ^Throwable (.getCause ^Throwable ex)))
38+
39+
(not (instance? IOException ex))
40+
(log/warn ex "error in TCP server")))
3541

3642
:channel-inactive
3743
([_ ctx]
@@ -98,7 +104,11 @@
98104
:exception-caught
99105
([_ ctx ex]
100106
(when-not (d/error! d ex)
101-
(log/warn ex "error in TCP client")))
107+
(if (netty/ssl-handshake-error? ex)
108+
;; do not need to log an entire stack trace when SSL handshake failed
109+
(log/warn "SSL handshake failure:"
110+
(.getMessage ^Throwable (.getCause ^Throwable ex)))
111+
(log/warn ex "error in TCP client"))))
102112

103113
:channel-inactive
104114
([_ ctx]

0 commit comments

Comments
 (0)