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

com.fireflysource.net.tcp.secure.conscrypt.FileConscryptSSLContextFactory Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
package com.fireflysource.net.tcp.secure.conscrypt;

import javax.net.ssl.SSLContext;
import java.io.InputStream;

/**
 * @author Pengtao Qiu
 */
public class FileConscryptSSLContextFactory extends AbstractConscryptSecureEngineFactory {

    private SSLContext sslContext;

    public FileConscryptSSLContextFactory(String path, String keystorePassword, String keyPassword, String keyStoreType) {
        this(FileConscryptSSLContextFactory.class.getClassLoader().getResourceAsStream(path), keystorePassword, keyPassword,
                keyStoreType, null, null, null);
    }

    public FileConscryptSSLContextFactory(
            InputStream inputStream, String keystorePassword, String keyPassword,
            String keyStoreType,
            String keyManagerFactoryType,
            String trustManagerFactoryType,
            String sslProtocol) {
        try (InputStream in = inputStream) {
            sslContext = getSSLContext(in, keystorePassword, keyPassword,
                    keyStoreType, keyManagerFactoryType, trustManagerFactoryType, sslProtocol);
        } catch (Exception e) {
            LOG.error(e, () -> "get SSL context exception");
        }
    }

    @Override
    public SSLContext getSSLContext() {
        return sslContext;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy