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

com.github.akurilov.commons.net.ssl.SslContext Maven / Gradle / Ivy

There is a newer version: 2.3.6
Show newest version
package com.github.akurilov.commons.net.ssl;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

/**
 Created by kurila on 12.05.16.
 */
public final class SslContext {

	private SslContext() {}

	private static SSLContext getInstance()
	throws NoSuchAlgorithmException, KeyManagementException {
		final SSLContext sslContext = SSLContext.getInstance("TLS");
		sslContext.init(
			null, new TrustManager[] { X509TrustAllManager.INSTANCE }, new SecureRandom()
		);
		return sslContext;
	}

	public static final SSLContext INSTANCE;
	static {
		try {
			INSTANCE = getInstance();
		} catch(final Exception e) {
			throw new RuntimeException(e);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy