Search in sources :

Example 1 with ServerX509TrustManager

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);
    }
}
Also used : ServerX509TrustManager(com.vmware.photon.controller.model.security.ssl.ServerX509TrustManager) SslTrustCertificateState(com.vmware.photon.controller.model.security.service.SslTrustCertificateService.SslTrustCertificateState)

Example 2 with ServerX509TrustManager

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;
}
Also used : ServerX509TrustManager(com.vmware.photon.controller.model.security.ssl.ServerX509TrustManager) BasicConnection(com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection)

Aggregations

ServerX509TrustManager (com.vmware.photon.controller.model.security.ssl.ServerX509TrustManager)2 BasicConnection (com.vmware.photon.controller.model.adapters.vsphere.util.connection.BasicConnection)1 SslTrustCertificateState (com.vmware.photon.controller.model.security.service.SslTrustCertificateService.SslTrustCertificateState)1