use of org.apache.zookeeper.common.ClientX509Util in project zookeeper by apache.
the class SaslKerberosAuthOverSSLTest method setUpSSLWithNoAuth.
public ClientX509Util setUpSSLWithNoAuth() {
String testDataPath = System.getProperty("test.data.dir", "src/test/resources/data");
System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, "org.apache.zookeeper.server.NettyServerCnxnFactory");
System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
System.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
System.setProperty("zookeeper.ssl.clientAuth", "none");
System.setProperty("zookeeper.ssl.quorum.clientAuth", "none");
ClientX509Util x509Util = new ClientX509Util();
System.setProperty(x509Util.getSslTruststoreLocationProperty(), testDataPath + "/ssl/testTrustStore.jks");
System.setProperty(x509Util.getSslTruststorePasswdProperty(), "testpass");
System.setProperty(x509Util.getSslKeystoreLocationProperty(), testDataPath + "/ssl/testKeyStore.jks");
System.setProperty(x509Util.getSslKeystorePasswdProperty(), "testpass");
return x509Util;
}
use of org.apache.zookeeper.common.ClientX509Util in project zookeeper by apache.
the class SSLAuthTest method setUpSecure.
public static ClientX509Util setUpSecure() throws Exception {
ClientX509Util x509Util = new ClientX509Util();
String testDataPath = System.getProperty("test.data.dir", "src/test/resources/data");
System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, "org.apache.zookeeper.server.NettyServerCnxnFactory");
System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
System.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
System.setProperty(x509Util.getSslAuthProviderProperty(), "x509");
System.setProperty(x509Util.getSslKeystoreLocationProperty(), testDataPath + "/ssl/testKeyStore.jks");
System.setProperty(x509Util.getSslKeystorePasswdProperty(), "testpass");
System.setProperty(x509Util.getSslTruststoreLocationProperty(), testDataPath + "/ssl/testTrustStore.jks");
System.setProperty(x509Util.getSslTruststorePasswdProperty(), "testpass");
System.setProperty("javax.net.debug", "ssl");
System.setProperty("zookeeper.authProvider.x509", "org.apache.zookeeper.server.auth.X509AuthenticationProvider");
return x509Util;
}
use of org.apache.zookeeper.common.ClientX509Util in project zookeeper by apache.
the class UnifiedServerSocketModeDetectionTest method init.
public void init(boolean useSecureClient) throws Exception {
x509Util = new ClientX509Util();
x509TestContext.setSystemProperties(x509Util, KeyStoreFileType.JKS, KeyStoreFileType.JKS);
System.setProperty(x509Util.getSslHandshakeDetectionTimeoutMillisProperty(), "100");
workerPool = Executors.newCachedThreadPool();
port = PortAssignment.unique();
localServerAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), port);
listeningSocket = new UnifiedServerSocket(x509Util, true);
listeningSocket.bind(localServerAddress);
Future<UnifiedServerSocket.UnifiedSocket> acceptFuture;
acceptFuture = workerPool.submit(new Callable<UnifiedServerSocket.UnifiedSocket>() {
@Override
public UnifiedServerSocket.UnifiedSocket call() throws Exception {
try {
return (UnifiedServerSocket.UnifiedSocket) listeningSocket.accept();
} catch (IOException e) {
LOG.error("Error in accept()", e);
throw e;
}
}
});
if (useSecureClient) {
clientSocket = x509Util.createSSLSocket();
clientSocket.connect(localServerAddress);
} else {
clientSocket = new Socket();
clientSocket.connect(localServerAddress);
clientSocket.getOutputStream().write(new byte[] { 1, 2, 3, 4, 5 });
}
serverSideSocket = acceptFuture.get();
}
use of org.apache.zookeeper.common.ClientX509Util in project zookeeper by apache.
the class UnifiedServerSocketTest method setUp.
public void setUp() throws Exception {
localServerAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), PortAssignment.unique());
x509Util = new ClientX509Util();
x509TestContext.setSystemProperties(x509Util, KeyStoreFileType.JKS, KeyStoreFileType.JKS);
}
use of org.apache.zookeeper.common.ClientX509Util in project zookeeper by apache.
the class QuorumPeerConfigTest method testCustomSSLAuth.
/**
* https://issues.apache.org/jira/browse/ZOOKEEPER-2297
*/
@Test
public void testCustomSSLAuth() throws IOException {
try (ClientX509Util x509Util = new ClientX509Util()) {
System.setProperty(x509Util.getSslAuthProviderProperty(), "y509");
QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
try {
Properties zkProp = getDefaultZKProperties();
zkProp.setProperty("secureClientPort", "12345");
quorumPeerConfig.parseProperties(zkProp);
fail("ConfigException is expected");
} catch (ConfigException e) {
assertNotNull(e.getMessage());
}
}
}
Aggregations