use of com.navercorp.pinpoint.grpc.util.Resource in project pinpoint by naver.
the class SslContextFactory method create.
public static SslContext create(SslClientConfig clientConfig) throws SSLException {
Objects.requireNonNull(clientConfig, "clientConfig");
if (!clientConfig.isEnable()) {
throw new IllegalArgumentException("sslConfig is disabled.");
}
SslProvider sslProvider = getSslProvider(clientConfig.getSslProviderType());
SslContextBuilder sslContextBuilder = null;
try {
sslContextBuilder = SslContextBuilder.forClient();
Resource trustCertResource = clientConfig.getTrustCertResource();
if (trustCertResource != null) {
sslContextBuilder.trustManager(trustCertResource.getInputStream());
} else {
// Loads default Root CA certificates (generally, from JAVA_HOME/lib/cacerts)
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore) null);
sslContextBuilder.trustManager(trustManagerFactory);
}
SslContext sslContext = createSslContext(sslContextBuilder, sslProvider);
assertValidCipherSuite(sslContext);
return sslContext;
} catch (SSLException e) {
throw e;
} catch (Exception e) {
throw new SSLException(e);
}
}
use of com.navercorp.pinpoint.grpc.util.Resource in project pinpoint by naver.
the class SslContextFactory method create.
public static SslContext create(SslServerConfig serverConfig) throws SSLException {
Objects.requireNonNull(serverConfig, "serverConfig");
SslProvider sslProvider = getSslProvider(serverConfig.getSslProviderType());
SslContextBuilder sslContextBuilder;
try {
Resource keyCertChainFileResource = serverConfig.getKeyCertChainResource();
Resource keyResource = serverConfig.getKeyResource();
sslContextBuilder = SslContextBuilder.forServer(keyCertChainFileResource.getInputStream(), keyResource.getInputStream());
SslContext sslContext = createSslContext(sslContextBuilder, sslProvider);
assertValidCipherSuite(sslContext);
return sslContext;
} catch (SSLException e) {
throw e;
} catch (Exception e) {
throw new SSLException(e);
}
}
use of com.navercorp.pinpoint.grpc.util.Resource in project pinpoint by naver.
the class DefaultChannelFactoryBuilder method build.
@Override
public ChannelFactory build() {
logger.info("build ChannelFactory:{}", factoryName);
Objects.requireNonNull(headerFactory, "headerFactory");
Objects.requireNonNull(clientOption, "clientOption");
SslClientConfig sslClientConfig = SslClientConfig.DISABLED_CONFIG;
if (sslOption != null && sslOption.isEnable()) {
String providerType = sslOption.getProviderType();
Resource trustCertResource = sslOption.getTrustCertResource();
sslClientConfig = new SslClientConfig(true, providerType, trustCertResource);
}
return new DefaultChannelFactory(factoryName, executorQueueSize, headerFactory, nameResolverProvider, clientOption, sslClientConfig, clientInterceptorList);
}
Aggregations