You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2021/01/25 18:53:27 UTC

[httpcomponents-core] branch 4.4.x updated: HTTPCORE-660: convert RuntimeExceptions thrown by SSLSetupHandler#verify to SSLExceptions

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch 4.4.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git


The following commit(s) were added to refs/heads/4.4.x by this push:
     new 05d9143  HTTPCORE-660: convert RuntimeExceptions thrown by SSLSetupHandler#verify to SSLExceptions
05d9143 is described below

commit 05d914304ecf41c263cbcb6bcea86e121d2a0bdd
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Mon Jan 25 19:49:06 2021 +0100

    HTTPCORE-660: convert RuntimeExceptions thrown by SSLSetupHandler#verify to SSLExceptions
---
 .../main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java   | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java b/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
index 4f156df..b829f11 100644
--- a/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
+++ b/httpcore-nio/src/main/java/org/apache/http/nio/reactor/ssl/SSLIOSession.java
@@ -368,7 +368,13 @@ public class SSLIOSession implements IOSession, SessionBufferStatus, SocketAcces
         // It is never generated by SSLEngine.getHandshakeStatus().
         if (result != null && result.getHandshakeStatus() == HandshakeStatus.FINISHED) {
             if (this.handler != null) {
-                this.handler.verify(this.session, this.sslEngine.getSession());
+                try {
+                    this.handler.verify(this.session, this.sslEngine.getSession());
+                } catch (final RuntimeException ex) {
+                    // Some libraries can throw a plan RuntimeException from #verify method
+                    // in case of a hostname verification failure in violation of the API contract
+                    throw convert(ex);
+                }
             }
         }
     }