All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.firefly.net.tcp.ssl.NoCheckSSLContextFactory Maven / Gradle / Ivy

There is a newer version: 5.0.0-dev6
Show newest version
package com.firefly.net.tcp.ssl;

import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public class NoCheckSSLContextFactory extends AbstractSSLContextFactory {

	@Override
	public SSLContext getSSLContext() {
		try {
			X509TrustManager tm = new X509TrustManager() {
				@Override
				public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
				}

				@Override
				public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
				}

				@Override
				public X509Certificate[] getAcceptedIssuers() {
					return null;
				}
			};
			return getSSLContextWithManager(null, new TrustManager[] { tm }, null);
		} catch (Throwable e) {
			log.error("get SSL context error", e);
			return null;
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy