use of io.vertx.core.net.PfxOptions in project vert.x by eclipse.
the class KeyStoreTest method testPKCS12Value.
@Test
public void testPKCS12Value() throws Exception {
PfxOptions options = Cert.SERVER_PKCS12.get();
Buffer store = vertx.fileSystem().readFileBlocking(options.getPath());
options.setPath(null).setValue(store);
testKeyStore(options);
}
use of io.vertx.core.net.PfxOptions in project vert.x by eclipse.
the class KeyStoreTest method testKeyOptionsEquality.
@Test
public void testKeyOptionsEquality() {
JksOptions jksOptions = Cert.SERVER_JKS.get();
JksOptions jksOptionsCopy = new JksOptions(jksOptions);
PfxOptions pfxOptions = Cert.SERVER_PKCS12.get();
PfxOptions pfxOptionsCopy = new PfxOptions(pfxOptions);
PemKeyCertOptions pemKeyCertOptions = Cert.SERVER_PEM.get();
PemKeyCertOptions pemKeyCertOptionsCopy = new PemKeyCertOptions(pemKeyCertOptions);
assertEquals(jksOptions, jksOptionsCopy);
assertEquals(jksOptions.hashCode(), jksOptionsCopy.hashCode());
assertEquals(pfxOptions, pfxOptionsCopy);
assertEquals(pfxOptions.hashCode(), pfxOptionsCopy.hashCode());
assertEquals(pemKeyCertOptions, pemKeyCertOptionsCopy);
assertEquals(pemKeyCertOptions.hashCode(), pemKeyCertOptionsCopy.hashCode());
}
use of io.vertx.core.net.PfxOptions in project vert.x by eclipse.
the class KeyStoreTest method testPKCS12OptionsJson.
@Test
public void testPKCS12OptionsJson() throws Exception {
PfxOptions options = new PfxOptions(new JsonObject());
assertEquals(null, options.getPassword());
assertEquals(null, options.getPath());
assertEquals(null, options.getValue());
String password = TestUtils.randomAlphaString(100);
String path = TestUtils.randomAlphaString(100);
String value = TestUtils.randomAlphaString(100);
options = new PfxOptions(new JsonObject().put("password", password).put("path", path).put("value", value.getBytes()));
assertEquals(password, options.getPassword());
assertEquals(path, options.getPath());
assertEquals(Buffer.buffer(value), options.getValue());
}
use of io.vertx.core.net.PfxOptions in project vert.x by eclipse.
the class KeyStoreTest method testCopyPKCS12Options.
@Test
public void testCopyPKCS12Options() throws Exception {
PfxOptions options = new PfxOptions();
String password = TestUtils.randomAlphaString(100);
String path = TestUtils.randomAlphaString(100);
Buffer value = Buffer.buffer(TestUtils.randomAlphaString(100));
options.setPassword(password);
options.setPath(path);
options.setValue(value);
options = new PfxOptions(options);
assertEquals(password, options.getPassword());
assertEquals(path, options.getPath());
assertEquals(value, options.getValue());
options = new PfxOptions(options.toJson());
assertEquals(password, options.getPassword());
assertEquals(path, options.getPath());
assertEquals(value, options.getValue());
}
use of io.vertx.core.net.PfxOptions in project java-chassis by ServiceComb.
the class VertxTLSBuilder method buildTCPSSLOptions.
private static TCPSSLOptions buildTCPSSLOptions(SSLOption sslOption, SSLCustom sslCustom, TCPSSLOptions httpClientOptions) {
httpClientOptions.setSsl(true);
if (isFileExists(sslCustom.getFullPath(sslOption.getKeyStore()))) {
if (STORE_PKCS12.equalsIgnoreCase(sslOption.getKeyStoreType())) {
PfxOptions keyPfxOptions = new PfxOptions();
keyPfxOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore()));
keyPfxOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray())));
httpClientOptions.setPfxKeyCertOptions(keyPfxOptions);
} else if (STORE_JKS.equalsIgnoreCase(sslOption.getKeyStoreType())) {
JksOptions keyJksOptions = new JksOptions();
keyJksOptions.setPath(sslCustom.getFullPath(sslOption.getKeyStore()));
keyJksOptions.setPassword(new String(sslCustom.decode(sslOption.getKeyStoreValue().toCharArray())));
httpClientOptions.setKeyStoreOptions(keyJksOptions);
} else {
throw new IllegalArgumentException("invalid key store type.");
}
}
if (isFileExists(sslCustom.getFullPath(sslOption.getTrustStore()))) {
if (STORE_PKCS12.equalsIgnoreCase(sslOption.getTrustStoreType())) {
PfxOptions trustPfxOptions = new PfxOptions();
trustPfxOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore()));
trustPfxOptions.setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray())));
httpClientOptions.setPfxTrustOptions(trustPfxOptions);
} else if (STORE_JKS.equalsIgnoreCase(sslOption.getTrustStoreType())) {
JksOptions trustJksOptions = new JksOptions();
trustJksOptions.setPath(sslCustom.getFullPath(sslOption.getTrustStore()));
trustJksOptions.setPassword(new String(sslCustom.decode(sslOption.getTrustStoreValue().toCharArray())));
httpClientOptions.setTrustStoreOptions(trustJksOptions);
} else {
throw new IllegalArgumentException("invalid trust store type.");
}
}
for (String protocol : sslOption.getProtocols().split(",")) {
httpClientOptions.addEnabledSecureTransportProtocol(protocol);
}
for (String cipher : SSLManager.getEnalbedCiphers(sslOption.getCiphers())) {
httpClientOptions.addEnabledCipherSuite(cipher);
}
if (isFileExists(sslCustom.getFullPath(sslOption.getCrl()))) {
httpClientOptions.addCrlPath(sslCustom.getFullPath(sslOption.getCrl()));
}
return httpClientOptions;
}
Aggregations