Skip to content

Commit

Permalink
✨ 代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunMengLu committed Nov 16, 2024
1 parent 8d2adda commit df7a76e
Showing 1 changed file with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand All @@ -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 {
}
Expand All @@ -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 {

}
}

0 comments on commit df7a76e

Please sign in to comment.