Skip to content

Commit

Permalink
Downgrade log level for close notify messages
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed May 25, 2023
1 parent 464ae19 commit 137d4ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kotlin-mbedtls/src/main/kotlin/org/opencoap/ssl/SslConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,14 @@ class SslConfig(
private object LogCallback : Callback {
private val logger = LoggerFactory.getLogger(MbedtlsApi::class.java)
fun callback(ctx: Pointer?, debugLevel: Int, fileName: String, lineNumber: Int, message: String?) {
// seems like a bug in log levels:
if (debugLevel == 1 && message?.startsWith("got supported group") == true) return
if (debugLevel == 1) {
// seems like a bug in log levels:
if (message?.startsWith("got supported group") == true) return

// logs when close notify is received
if (message?.startsWith("mbedtls_ssl_handle_message_type() returned -30848 (-0x7880)") == true) return
if (message?.startsWith("mbedtls_ssl_read_record() returned -30848 (-0x7880)") == true) return
}

when (debugLevel) {
1 -> logger.warn("[mbedtls {}:{}] {} ", fileName.substringAfterLast('/'), lineNumber, message?.trim())
Expand Down

0 comments on commit 137d4ca

Please sign in to comment.