use of com.sequenceiq.cloudbreak.polling.nginx.NginxPollerObject in project cloudbreak by hortonworks.
the class TlsSetupService method setupTls.
public void setupTls(Stack stack, InstanceMetaData gwInstance) throws CloudbreakException {
try {
SavingX509TrustManager x509TrustManager = new SavingX509TrustManager();
TrustManager[] trustManagers = { x509TrustManager };
SSLContext sslContext = SslConfigurator.newInstance().createSSLContext();
sslContext.init(null, trustManagers, new SecureRandom());
Client client = RestClientUtil.createClient(sslContext, false);
Integer gatewayPort = stack.getGatewayPort();
String ip = gatewayConfigService.getGatewayIp(stack, gwInstance);
LOGGER.debug("Trying to fetch the server's certificate: {}:{}", ip, gatewayPort);
nginxPollerService.pollWithAbsoluteTimeout(nginxCertListenerTask, new NginxPollerObject(client, ip, gatewayPort, x509TrustManager), POLLING_INTERVAL, TEN_MIN, MAX_FAILURE);
WebTarget nginxTarget = client.target(String.format("https://%s:%d", ip, gatewayPort));
nginxTarget.path("/").request().get().close();
X509Certificate[] chain = x509TrustManager.getChain();
String serverCert = PkiUtil.convert(chain[0]);
InstanceMetaData metaData = getInstanceMetaData(gwInstance);
metaData.setServerCert(BaseEncoding.base64().encode(serverCert.getBytes()));
instanceMetaDataService.save(metaData);
} catch (Exception e) {
throw new CloudbreakException("Failed to retrieve the server's certificate from Nginx." + " Please check your security group is open enough and the Management Console can access your VPC and subnet." + " Please also Make sure your Subnets can route to the internet and you have public DNS and IP options enabled." + " Refer to Cloudera documentation at" + " https://docs.cloudera.com/management-console/cloud/proxy/topics/mc-outbound-internet-access-and-proxy.html", e);
}
}
use of com.sequenceiq.cloudbreak.polling.nginx.NginxPollerObject in project cloudbreak by hortonworks.
the class TlsSetupService method setupTls.
public void setupTls(Long stackId, InstanceMetaData gwInstance) throws CloudbreakException {
try {
SavingX509TrustManager x509TrustManager = new SavingX509TrustManager();
TrustManager[] trustManagers = { x509TrustManager };
SSLContext sslContext = SslConfigurator.newInstance().createSSLContext();
sslContext.init(null, trustManagers, new SecureRandom());
Client client = RestClientUtil.createClient(sslContext, false);
String ip = gwInstance.getPublicIpWrapper();
Stack stack = stackRepository.findById(stackId).get();
Integer gatewayPort = stack.getGatewayport();
LOGGER.debug("Trying to fetch the server's certificate: {}:{}", ip, gatewayPort);
nginxPollerService.pollWithAbsoluteTimeout(nginxCertListenerTask, new NginxPollerObject(client, ip, gatewayPort, x509TrustManager), POLLING_INTERVAL, FIVE_MIN, MAX_FAILURE);
WebTarget nginxTarget = client.target(String.format("https://%s:%d", ip, gatewayPort));
nginxTarget.path("/").request().get().close();
X509Certificate[] chain = x509TrustManager.getChain();
String serverCert = PkiUtil.convert(chain[0]);
InstanceMetaData metaData = getInstanceMetaData(gwInstance);
metaData.setServerCert(BaseEncoding.base64().encode(serverCert.getBytes()));
instanceMetaDataRepository.save(metaData);
} catch (Exception e) {
throw new CloudbreakException("Failed to retrieve the server's certificate from Nginx." + " Please check your security group is open enough and Management Console can access your VPC and subnet" + " Please also Make sure your Subnets can route to the internet and you have public DNS and IP options enabled." + " Refer to Cloudera documentation at" + " https://docs.cloudera.com/management-console/cloud/proxy/topics/mc-outbound-internet-access-and-proxy.html", e);
}
}
Aggregations