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

gov.nasa.pds.registry.common.connection.SSLUtils Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package gov.nasa.pds.registry.common.connection;


import java.security.SecureRandom;

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


/**
 * TLS/SSL utility methods.
 * 
 * @author karpenko
 */
class SSLUtils
{
    /**
     * Create "trust all" SSL context to support self-signed certificates.
     * @return SSL context object
     * @throws Exception an exception
     */
    public static SSLContext createTrustAllContext() throws Exception
    {
        TrustManager[] trustManagers = new TrustManager[1];
        trustManagers[0] = new TrustAllManager();
        
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustManagers, new SecureRandom());
        return sc;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy