Search in sources :

Example 6 with Configuration

use of org.eclipse.californium.elements.config.Configuration in project californium by eclipse.

the class LibCoapServerMbedTlsInteroperabilityTest method testLibCoapServerEcdsaRsaSigAlgTrust.

@Test
public void testLibCoapServerEcdsaRsaSigAlgTrust() throws Exception {
    CipherSuite cipherSuite = CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8;
    processUtil.setCertificate(SERVER_CA_RSA_CERTIFICATE);
    processUtil.startupServer(ACCEPT, TRUST, cipherSuite);
    DtlsConnectorConfig.Builder dtlsBuilder = DtlsConnectorConfig.builder(new Configuration()).setAsList(DtlsConfig.DTLS_SIGNATURE_AND_HASH_ALGORITHMS, SignatureAndHashAlgorithm.SHA256_WITH_ECDSA);
    californiumUtil.start(BIND, dtlsBuilder, ScandiumUtil.TRUST_ROOT, cipherSuite);
    connect(true);
    californiumUtil.assertPrincipalType(X509CertPath.class);
}
Also used : Configuration(org.eclipse.californium.elements.config.Configuration) CipherSuite(org.eclipse.californium.scandium.dtls.cipher.CipherSuite) DtlsConnectorConfig(org.eclipse.californium.scandium.config.DtlsConnectorConfig) Test(org.junit.Test)

Example 7 with Configuration

use of org.eclipse.californium.elements.config.Configuration in project californium by eclipse.

the class LibCoapServerOpensslInteroperabilityTest method testLibCoapServerEcdsaRsaSigAlgTrust.

@Test
public void testLibCoapServerEcdsaRsaSigAlgTrust() throws Exception {
    CipherSuite cipherSuite = CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8;
    processUtil.setCertificate(SERVER_CA_RSA_CERTIFICATE);
    processUtil.startupServer(ACCEPT, TRUST, cipherSuite);
    DtlsConnectorConfig.Builder dtlsBuilder = DtlsConnectorConfig.builder(new Configuration()).setAsList(DtlsConfig.DTLS_SIGNATURE_AND_HASH_ALGORITHMS, SignatureAndHashAlgorithm.SHA256_WITH_ECDSA);
    californiumUtil.start(BIND, dtlsBuilder, ScandiumUtil.TRUST_ROOT, cipherSuite);
    connect(true);
    californiumUtil.assertPrincipalType(X509CertPath.class);
}
Also used : Configuration(org.eclipse.californium.elements.config.Configuration) CipherSuite(org.eclipse.californium.scandium.dtls.cipher.CipherSuite) DtlsConnectorConfig(org.eclipse.californium.scandium.config.DtlsConnectorConfig) Test(org.junit.Test)

Example 8 with Configuration

use of org.eclipse.californium.elements.config.Configuration in project californium by eclipse.

the class LibCoapServerOpensslInteroperabilityTest method testLibCoapServerEcdsaRsaSigAlg.

@Test
public void testLibCoapServerEcdsaRsaSigAlg() throws Exception {
    CipherSuite cipherSuite = CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8;
    processUtil.setCertificate(SERVER_CA_RSA_CERTIFICATE);
    processUtil.startupServer(ACCEPT, CHAIN, cipherSuite);
    DtlsConnectorConfig.Builder dtlsBuilder = DtlsConnectorConfig.builder(new Configuration()).setAsList(DtlsConfig.DTLS_SIGNATURE_AND_HASH_ALGORITHMS, SignatureAndHashAlgorithm.SHA256_WITH_ECDSA);
    californiumUtil.start(BIND, dtlsBuilder, ScandiumUtil.TRUST_ROOT, cipherSuite);
    connect(true);
    californiumUtil.assertPrincipalType(X509CertPath.class);
}
Also used : Configuration(org.eclipse.californium.elements.config.Configuration) CipherSuite(org.eclipse.californium.scandium.dtls.cipher.CipherSuite) DtlsConnectorConfig(org.eclipse.californium.scandium.config.DtlsConnectorConfig) Test(org.junit.Test)

Example 9 with Configuration

use of org.eclipse.californium.elements.config.Configuration in project californium by eclipse.

the class ServerSerializationTest method setup.

private EncryptedServersSerializationUtil setup(Connector... connectors) {
    EncryptedServersSerializationUtil util = new EncryptedServersSerializationUtil();
    Configuration config = network.createStandardTestConfig();
    CoapServer server = new CoapServer(config);
    for (Connector connector : connectors) {
        CoapEndpoint endpoint = CoapEndpoint.builder().setConfiguration(config).setConnector(connector).build();
        server.addEndpoint(endpoint);
    }
    util.add(server);
    return util;
}
Also used : UDPConnector(org.eclipse.californium.elements.UDPConnector) PersistentConnector(org.eclipse.californium.elements.PersistentConnector) Connector(org.eclipse.californium.elements.Connector) Configuration(org.eclipse.californium.elements.config.Configuration) CoapServer(org.eclipse.californium.core.CoapServer) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint)

Example 10 with Configuration

use of org.eclipse.californium.elements.config.Configuration in project leshan by eclipse.

the class LeshanBootstrapServerDemo method createBsLeshanServer.

public static LeshanBootstrapServer createBsLeshanServer(LeshanBsServerDemoCLI cli, EditableBootstrapConfigStore bsConfigStore, EditableSecurityStore securityStore) throws Exception {
    // Prepare LWM2M server
    LeshanBootstrapServerBuilder builder = new LeshanBootstrapServerBuilder();
    // Create CoAP Config
    File configFile = new File(CF_CONFIGURATION_FILENAME);
    Configuration coapConfig = LeshanBootstrapServerBuilder.createDefaultCoapConfiguration();
    // these configuration values are always overwritten by CLI
    // therefore set them to transient.
    coapConfig.setTransient(DtlsConfig.DTLS_RECOMMENDED_CIPHER_SUITES_ONLY);
    coapConfig.setTransient(DtlsConfig.DTLS_CONNECTION_ID_LENGTH);
    if (configFile.isFile()) {
        coapConfig.load(configFile);
    } else {
        coapConfig.store(configFile, CF_CONFIGURATION_HEADER);
    }
    builder.setCoapConfig(coapConfig);
    // ports from CoAP Config if needed
    builder.setLocalAddress(cli.main.localAddress, cli.main.localPort == null ? coapConfig.get(CoapConfig.COAP_PORT) : cli.main.localPort);
    builder.setLocalSecureAddress(cli.main.secureLocalAddress, cli.main.secureLocalPort == null ? coapConfig.get(CoapConfig.COAP_SECURE_PORT) : cli.main.secureLocalPort);
    // Create DTLS Config
    DtlsConnectorConfig.Builder dtlsConfig = DtlsConnectorConfig.builder(coapConfig);
    dtlsConfig.set(DtlsConfig.DTLS_RECOMMENDED_CIPHER_SUITES_ONLY, !cli.dtls.supportDeprecatedCiphers);
    if (cli.dtls.cid != null) {
        dtlsConfig.set(DtlsConfig.DTLS_CONNECTION_ID_LENGTH, cli.dtls.cid);
    }
    if (cli.identity.isx509()) {
        // use X.509 mode (+ RPK)
        builder.setPrivateKey(cli.identity.getPrivateKey());
        builder.setCertificateChain(cli.identity.getCertChain());
        // Define trust store
        List<Certificate> trustStore = cli.identity.getTrustStore();
        builder.setTrustedCertificates(trustStore.toArray(new Certificate[trustStore.size()]));
    } else if (cli.identity.isRPK()) {
        // use RPK only
        builder.setPublicKey(cli.identity.getPublicKey());
        builder.setPrivateKey(cli.identity.getPrivateKey());
    }
    // Set DTLS Config
    builder.setDtlsConfig(dtlsConfig);
    // Create Models
    List<ObjectModel> models = ObjectLoader.loadDefault();
    if (cli.main.modelsFolder != null) {
        models.addAll(ObjectLoader.loadObjectsFromDir(cli.main.modelsFolder, true));
    }
    builder.setObjectModelProvider(new VersionedBootstrapModelProvider(models));
    builder.setConfigStore(bsConfigStore);
    builder.setSecurityStore(new BootstrapSecurityStoreAdapter(securityStore));
    return builder.build();
}
Also used : LeshanBootstrapServerBuilder(org.eclipse.leshan.server.californium.bootstrap.LeshanBootstrapServerBuilder) ObjectModel(org.eclipse.leshan.core.model.ObjectModel) VersionedBootstrapModelProvider(org.eclipse.leshan.server.model.VersionedBootstrapModelProvider) Configuration(org.eclipse.californium.elements.config.Configuration) BootstrapSecurityStoreAdapter(org.eclipse.leshan.server.security.BootstrapSecurityStoreAdapter) File(java.io.File) DtlsConnectorConfig(org.eclipse.californium.scandium.config.DtlsConnectorConfig) Certificate(java.security.cert.Certificate)

Aggregations

Configuration (org.eclipse.californium.elements.config.Configuration)152 Test (org.junit.Test)55 DtlsConnectorConfig (org.eclipse.californium.scandium.config.DtlsConnectorConfig)52 CoapEndpoint (org.eclipse.californium.core.network.CoapEndpoint)44 CipherSuite (org.eclipse.californium.scandium.dtls.cipher.CipherSuite)30 CoapServer (org.eclipse.californium.core.CoapServer)24 InetSocketAddress (java.net.InetSocketAddress)21 Before (org.junit.Before)19 DTLSConnector (org.eclipse.californium.scandium.DTLSConnector)16 Endpoint (org.eclipse.californium.core.network.Endpoint)14 CoapResource (org.eclipse.californium.core.CoapResource)7 MessageTracer (org.eclipse.californium.core.network.interceptors.MessageTracer)7 Response (org.eclipse.californium.core.coap.Response)6 Exchange (org.eclipse.californium.core.network.Exchange)6 CoapExchange (org.eclipse.californium.core.server.resources.CoapExchange)6 AdvancedSinglePskStore (org.eclipse.californium.scandium.dtls.pskstore.AdvancedSinglePskStore)6 InetAddress (java.net.InetAddress)5 CoapClient (org.eclipse.californium.core.CoapClient)5 Request (org.eclipse.californium.core.coap.Request)5 Builder (org.eclipse.californium.scandium.config.DtlsConnectorConfig.Builder)5