Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post mina update custom SSL filter removal #923

Merged
merged 2 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import quickfix.SessionID;
import quickfix.SessionSettings;
import quickfix.mina.CompositeIoFilterChainBuilder;
import quickfix.mina.CustomSslFilter;
import quickfix.mina.EventHandlingStrategy;
import quickfix.mina.NetworkingOptions;
import quickfix.mina.ProtocolFactory;
Expand Down Expand Up @@ -135,7 +134,7 @@ private void installSSL(AcceptorSocketDescriptor descriptor,
log.info("Installing SSL filter for {}", descriptor.getAddress());
SSLConfig sslConfig = descriptor.getSslConfig();
SSLContext sslContext = SSLContextFactory.getInstance(sslConfig);
SslFilter sslFilter = new CustomSslFilter(sslContext);
SslFilter sslFilter = new SslFilter(sslContext);
sslFilter.setNeedClientAuth(sslConfig.isNeedClientAuth());
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
: SSLSupport.getDefaultCipherSuites(sslContext));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import quickfix.SessionSettings;
import quickfix.SystemTime;
import quickfix.mina.CompositeIoFilterChainBuilder;
import quickfix.mina.CustomSslFilter;
import quickfix.mina.EventHandlingStrategy;
import quickfix.mina.NetworkingOptions;
import quickfix.mina.ProtocolFactory;
Expand Down Expand Up @@ -159,9 +158,8 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {

boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;

SslFilter sslFilter = null;
if (sslEnabled) {
sslFilter = installSslFilter(ioFilterChainBuilder);
installSslFilter(ioFilterChainBuilder);
}

ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));
Expand Down Expand Up @@ -192,17 +190,16 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {
ioConnector = newConnector;
}

private SslFilter installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder)
private void installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder)
throws GeneralSecurityException {
final SSLContext sslContext = SSLContextFactory.getInstance(sslConfig);
final SslFilter sslFilter = new CustomSslFilter(sslContext, false);
final SslFilter sslFilter = new SslFilter(sslContext, false);
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
: SSLSupport.getDefaultCipherSuites(sslContext));
sslFilter.setEnabledProtocols(sslConfig.getEnabledProtocols() != null ? sslConfig.getEnabledProtocols()
: SSLSupport.getSupportedProtocols(sslContext));
sslFilter.setEndpointIdentificationAlgorithm(sslConfig.getEndpointIdentificationAlgorithm());
ioFilterChainBuilder.addLast(SSLSupport.FILTER_NAME, sslFilter);
return sslFilter;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

package quickfix.mina.ssl;

import junit.framework.TestCase;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.session.IoSession;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quickfix.ApplicationAdapter;
import quickfix.ConfigError;
import quickfix.DefaultMessageFactory;
import quickfix.FixVersions;
import quickfix.Initiator;
import quickfix.MemoryStoreFactory;
import quickfix.Session;
import quickfix.SessionID;
Expand All @@ -43,14 +43,20 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class SecureSocketTest extends TestCase {
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class SecureSocketTest {

private final Logger log = LoggerFactory.getLogger(getClass());
private final int transportProtocol = ProtocolFactory.SOCKET;

protected void setUp() throws Exception {
@Before
public void setUp() throws Exception {
SystemTime.setTimeSource(null);
}

@Test
public void testLogonWithBadCertificate() throws Exception {
ServerThread serverThread = new ServerThread("nonexistent", "pwd");
try {
Expand Down Expand Up @@ -85,10 +91,12 @@ public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable
}
}

@Test
public void testLogonWithDefaultCertificate() throws Exception {
doLogonTest(null, null);
}

@Test
public void testLogonWithCustomCertificate() throws Exception {
doLogonTest("test.keystore", "quickfixjtestpw");
}
Expand All @@ -103,6 +111,7 @@ public void testLogonWithCustomCertificate() throws Exception {
* so that it's not cached by another test so that there are no false failures.
* The test-client.keystore key store is just a copy of test.keystore under a different name.
*/
@Test
public void testLogonWithBadCertificateOnInitiatorSide() throws Exception {
SessionID clientSessionID = new SessionID(FixVersions.BEGINSTRING_FIX42, "TW", "ISLD");
SessionSettings settings = getClientSessionSettings(clientSessionID);
Expand Down Expand Up @@ -177,14 +186,8 @@ private void assertLoggedOn(ClientApplication clientApplication, Session clientS
}

private class ClientApplication extends ApplicationAdapter {
public CountDownLatch logonLatch;
private Initiator initiator;
private boolean stopAfterLogon;

//public void stopAfterLogon(Initiator initiator) {
// this.initiator = initiator;
// this.stopAfterLogon = true;
//}
public CountDownLatch logonLatch;

public void setUpLogonExpectation() {
logonLatch = new CountDownLatch(1);
Expand All @@ -195,14 +198,11 @@ public void onLogon(SessionID sessionId) {
log.info("Releasing logon latch");
logonLatch.countDown();
}
if (stopAfterLogon) {
log.info("Stopping after logon");
initiator.stop();
}
}
}

private class ServerThread extends Thread {

private final ATServer server;

public ServerThread(String keyStoreName, String keyStorePassword) {
Expand All @@ -223,5 +223,4 @@ public void waitForInitialization() throws InterruptedException {
server.waitForInitialization();
}
}

}
Loading