Search in sources :

Example 1 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project cas by apereo.

the class IgniteTicketRegistry method configureSecureTransport.

private void configureSecureTransport() {
    final String nullKey = "NULL";
    if (StringUtils.isNotBlank(properties.getKeyStoreFilePath()) && StringUtils.isNotBlank(properties.getKeyStorePassword()) && StringUtils.isNotBlank(properties.getTrustStoreFilePath()) && StringUtils.isNotBlank(properties.getTrustStorePassword())) {
        final SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStoreFilePath(properties.getKeyStoreFilePath());
        sslContextFactory.setKeyStorePassword(properties.getKeyStorePassword().toCharArray());
        if (nullKey.equals(properties.getTrustStoreFilePath()) && nullKey.equals(properties.getTrustStorePassword())) {
            sslContextFactory.setTrustManagers(SslContextFactory.getDisabledTrustManager());
        } else {
            sslContextFactory.setTrustStoreFilePath(properties.getTrustStoreFilePath());
            sslContextFactory.setTrustStorePassword(properties.getKeyStorePassword().toCharArray());
        }
        if (StringUtils.isNotBlank(properties.getKeyAlgorithm())) {
            sslContextFactory.setKeyAlgorithm(properties.getKeyAlgorithm());
        }
        if (StringUtils.isNotBlank(properties.getProtocol())) {
            sslContextFactory.setProtocol(properties.getProtocol());
        }
        if (StringUtils.isNotBlank(properties.getTrustStoreType())) {
            sslContextFactory.setTrustStoreType(properties.getTrustStoreType());
        }
        if (StringUtils.isNotBlank(properties.getKeyStoreType())) {
            sslContextFactory.setKeyStoreType(properties.getKeyStoreType());
        }
        this.igniteConfiguration.setSslContextFactory(sslContextFactory);
    }
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory) ToString(lombok.ToString)

Example 2 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class JavaThinClient method configureSslInCluster.

void configureSslInCluster() {
    // tag::cluster-ssl-configuration[]
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    ClientConnectorConfiguration clientCfg = new ClientConnectorConfiguration();
    clientCfg.setSslEnabled(true);
    clientCfg.setUseIgniteSslContextFactory(false);
    SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setKeyStoreFilePath("/path/to/server.jks");
    sslContextFactory.setKeyStorePassword("123456".toCharArray());
    sslContextFactory.setTrustStoreFilePath("/path/to/trust.jks");
    sslContextFactory.setTrustStorePassword("123456".toCharArray());
    clientCfg.setSslContextFactory(sslContextFactory);
    igniteCfg.setClientConnectorConfiguration(clientCfg);
// end::cluster-ssl-configuration[]
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ClientConnectorConfiguration(org.apache.ignite.configuration.ClientConnectorConfiguration)

Example 3 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class Security method disableCertificateValidation.

@Test
void disableCertificateValidation() {
    // tag::disable-validation[]
    IgniteConfiguration igniteCfg = new IgniteConfiguration();
    SslContextFactory factory = new SslContextFactory();
    factory.setKeyStoreFilePath("keystore/node.jks");
    factory.setKeyStorePassword("123456".toCharArray());
    factory.setTrustManagers(SslContextFactory.getDisabledTrustManager());
    igniteCfg.setSslContextFactory(factory);
    // end::disable-validation[]
    Ignition.start(igniteCfg).close();
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Test(org.junit.jupiter.api.Test)

Example 4 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class GridCommandHandlerSslTest method createSslFactory.

/**
 * @return SSL factory.
 */
@NotNull
private SslContextFactory createSslFactory() {
    SslContextFactory factory = (SslContextFactory) GridTestUtils.sslFactory();
    factory.setCipherSuites(cipherSuites);
    return factory;
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with SslContextFactory

use of org.apache.ignite.ssl.SslContextFactory in project ignite by apache.

the class PlatformConfigurationUtils method writeSslContextFactory.

/**
 * Writes the SSL context factory.
 *
 * @param w Writer.
 * @param factory SslContextFactory.
 */
private static void writeSslContextFactory(BinaryRawWriter w, Factory<SSLContext> factory) {
    assert w != null;
    if (!(factory instanceof SslContextFactory)) {
        w.writeBoolean(false);
        return;
    }
    w.writeBoolean(true);
    SslContextFactory sslCtxFactory = (SslContextFactory) factory;
    w.writeString(sslCtxFactory.getKeyAlgorithm());
    w.writeString(sslCtxFactory.getKeyStoreType());
    w.writeString(sslCtxFactory.getKeyStoreFilePath());
    w.writeString(new String(sslCtxFactory.getKeyStorePassword()));
    w.writeString(sslCtxFactory.getProtocol());
    w.writeString(sslCtxFactory.getTrustStoreType());
    w.writeString(sslCtxFactory.getTrustStoreFilePath());
    w.writeString(new String(sslCtxFactory.getTrustStorePassword()));
}
Also used : SslContextFactory(org.apache.ignite.ssl.SslContextFactory)

Aggregations

SslContextFactory (org.apache.ignite.ssl.SslContextFactory)21 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)6 NotNull (org.jetbrains.annotations.NotNull)4 ClientConnectorConfiguration (org.apache.ignite.configuration.ClientConnectorConfiguration)3 SSLContext (javax.net.ssl.SSLContext)2 GridSslContextFactory (org.apache.ignite.internal.client.ssl.GridSslContextFactory)2 Before (org.junit.Before)2 Test (org.junit.jupiter.api.Test)2 Paths (java.nio.file.Paths)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SQLException (java.sql.SQLException)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 ExecutionException (java.util.concurrent.ExecutionException)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Factory (javax.cache.configuration.Factory)1 SSLException (javax.net.ssl.SSLException)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 ToString (lombok.ToString)1 lombok.val (lombok.val)1