|
From: Christoph J. <chr...@ma...> - 2021-01-26 13:50:26
|
Hi, you could use a SessionStateListener. See this SO post: https://stackoverflow.com/questions/61868398/quickfix-j-how-to-detect-when-connection-fails However, as mentioned in that post there might be cases where this does not help. There is an issue for that: https://github.com/quickfix-j/quickfixj/issues/342 Please check if the SessionStateListener works for your use cases. Cheers, Chris. On 26.01.21 14:33, Diana Susca wrote: > QuickFIX/J Documentation: http://www.quickfixj.org/documentation/ > QuickFIX/J Support: http://www.quickfixj.org/support/ > > > > Hi, I am looking for some help on how to catch exceptions occurring when SSL connections fail. > > I am creating a desktop application that will connect to a server and send FIX messages to it. > > I am starting from scratch, so this application is roughly the same as the Banzai application > provided in the quickfix/j sources. The application successfully connects with a simple, TCP > connection. > > Now I am trying to set up a secure connection (SocketUseSSL=Y and NeedClientAuth=Y). For a simple, > fixed setup, everything works fine. > But I want the desktop application to allow users to use their own keyStore and trustStore files, > which can be set up through a GUI. > The GUI needs to inform the user whether the connection to the server is successful or not, > through a message/log screen. I want to capture all the events and errors related to establishing > the connection via sockets and display it to the users. > But I cannot catch and handle the exceptions thrown when establishing the SSL connection (E.g: > invalid keystore password). This is because the connection is established by a different thread, > which, if it throws an exception, is not throwing it in the current application thread. > > To reproduce the issue you can run Banzai and either set an empty truststore or a truststore that > does not trust the server we are trying to connect. > > Basically the code: > try { > logon(initiator); > } catch (RuntimeError | ConfigError | IOException e) { > throw new RuntimeException("Failed to connect." + e.getMessage()); > } > > does not catch anything. > > The errors are the following: > Caused by: java.lang.RuntimeException: Unexpected error: > java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty > Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid > certification path to requested target > > > I would appreciate it if you had any ideas/thoughts on how this could be managed. > > Thank you. > > > > _______________________________________________ > Quickfixj-users mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfixj-users -- Christoph John Software Engineering T +49 241 557080-28 chr...@ma... MACD GmbH Oppenhoffallee 103 52066 Aachen, Germany www.macd.com Amtsgericht Aachen: HRB 8151 Ust.-Id: DE 813021663 Geschäftsführer: George Macdonald |