He-Pin opened a new issue, #3227:
URL: https://github.com/apache/pekko/issues/3227

   ### Motivation
   
   TLS 握手失败时,`TlsGraphStage` 发送 TLS close 
alert(`writeFailureAlert()`)而非直接中止连接传输。在某些安全场景下,应直接中止而非尝试优雅关闭。
   
   ### 当前代码行为
   
   `TlsGraphStage.scala` 中:
   
   ```scala
   // TlsGraphStage.scala:308-342
   private def doInbound(...): Unit = {
     try {
       engine.unwrap(...)
     } catch {
       case ex: SSLException =>
         failTls(ex, closeTransport = false)  // 发送 alert 而非中止
     }
   }
   
   // TlsGraphStage.scala:582-610
   private def failTls(ex: Throwable, closeTransport: Boolean): Unit = {
     if (!isClosed(in)) {
       writeFailureAlert()  // 尝试发送 TLS close alert
       ...
     }
   }
   ```
   
   `SSLException` 时 `closeTransport = false`,意味着先尝试发送 TLS close notification 
alert,然后才关闭。
   
   ### 预期行为
   
   对于握手失败(特别是证书验证失败等安全场景),应直接中止连接传输,不发送 alert(可能泄露信息或给攻击者提供信息)。
   
   ### 代码证据
   
   - 
`stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala:308-342`
 — doInbound SSLException 处理
   - 
`stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala:582-610`
 — failTls 实现
   
   ### 复现方式
   
   配置 TLS 连接使用无效证书,观察握手失败时的行为(是发送 alert 还是直接断开)。
   
   ### 影响范围
   
   - 模块:`pekko-stream` TLS 支持
   - 影响需要严格 TLS 安全策略的场景
   - 握手失败时发送 alert 可能泄露信息
   
   ### 备注
   
   此行为可能是合理的设计选择(遵循 TLS 规范的优雅关闭)。需要根据安全需求评估。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to