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);
}
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);
}
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);
}
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;
}
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();
}
Aggregations