From df7a76e0a9b39028add88e6edf3f96a103c9768b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=A2=A6=E6=8A=80=E6=9C=AF?= <596392912@qq.com> Date: Sat, 16 Nov 2024 09:20:43 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ssl/DisableValidationTrustManager.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java b/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java index 98163ba89..8968dee92 100644 --- a/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java +++ b/mica-core/src/main/java/net/dreamlu/mica/core/ssl/DisableValidationTrustManager.java @@ -16,8 +16,10 @@ package net.dreamlu.mica.core.ssl; +import javax.net.ssl.SSLEngine; import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; +import javax.net.ssl.X509ExtendedTrustManager; +import java.net.Socket; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; @@ -26,12 +28,8 @@ * * @author L.cm */ -public enum DisableValidationTrustManager implements X509TrustManager { - - /** - * 实例 - */ - INSTANCE; +public class DisableValidationTrustManager extends X509ExtendedTrustManager { + public static final DisableValidationTrustManager INSTANCE = new DisableValidationTrustManager(); /** * 获取 TrustManagers @@ -42,6 +40,11 @@ public TrustManager[] getTrustManagers() { return new TrustManager[]{this}; } + @Override + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } @@ -51,8 +54,22 @@ public void checkServerTrusted(X509Certificate[] x509Certificates, String s) thr } @Override - public X509Certificate[] getAcceptedIssuers() { - return new X509Certificate[0]; + public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { + } + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { + + } + + @Override + public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { + + } + + @Override + public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { + + } }