use of com.vmware.photon.controller.model.security.ssl.ServerX509TrustManager in project photon-model by vmware.
the class CertificateUtil method storeCertificate.
public static void storeCertificate(X509Certificate endCertificate, List<String> tenantLinks, ServiceHost host, ServiceRequestSender sender, CompletionHandler ch) {
SslTrustCertificateState certState = new SslTrustCertificateState();
if (tenantLinks != null) {
certState.tenantLinks = tenantLinks;
}
certState.certificate = CertificateUtil.toPEMformat(endCertificate);
SslTrustCertificateState.populateCertificateProperties(certState, endCertificate);
logger.info(String.format("Register certificate with common name: %s " + "and fingerprint: %s in trust store", certState.commonName, certState.fingerprint));
// save untrusted certificate to the trust store
Operation.createPost(host, SslTrustCertificateService.FACTORY_LINK).addPragmaDirective(Operation.PRAGMA_DIRECTIVE_FORCE_INDEX_UPDATE).setBody(certState).setCompletion(ch).sendWith(sender);
ServerX509TrustManager trustManager = ServerX509TrustManager.getInstance();
if (trustManager != null) {
logger.fine("Register Certificate " + certState);
trustManager.registerCertificate(certState);
}
}
use of com.vmware.photon.controller.model.security.ssl.ServerX509TrustManager in project photon-model by vmware.
the class VSphereEndpointAdapterService method createConnection.
private BasicConnection createConnection(URI adapterReference, AuthCredentialsServiceState auth) {
BasicConnection connection = new BasicConnection();
// ignores the certificate for testing purposes
if (VSPHERE_IGNORE_CERTIFICATE_WARNINGS) {
connection.setIgnoreSslErrors(true);
} else {
ServerX509TrustManager trustManager = ServerX509TrustManager.getInstance();
connection.setTrustManager(trustManager);
}
connection.setUsername(auth.privateKeyId);
connection.setPassword(EncryptionUtils.decrypt(auth.privateKey));
connection.setURI(adapterReference);
return connection;
}
Aggregations