Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

"java.io.EOFException: null" when connecting host with TLS v 1.2 enabled

96 views
Skip to first unread message

Kumar Kaliappan

unread,
Apr 11, 2025, 5:47:35 AMApr 11
to jPOS Users
Hi team,

My Springboot rest application(jdk 17 and jpos 2.0.0) is deployed in GKE and trying to connect the host(which is TLS v 1.2 protocol enabled) via Postchannel and send message.

I don't get any error while connecting the host and sending the message. When receiving the message, I get the below error.

java.io.EOFException: null

But the same is working when using Java Secure Socket connection without any certificates.

Please suggest me how to connect, send and receive using jpos.

Regards,
Kumar

Mark Salter

unread,
Apr 11, 2025, 7:56:10 AMApr 11
to jpos-...@googlegroups.com

Please provide the detail needed to help us help you.

How is your PostChannel configured?

Is a good place to start.  If you have no SSL cofiguratiinnonnit, the check the Programmers Guide as what to add to your configuration.

--
Mark

-- 
Mark



-------- Original Message --------
--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jpos-users/660160f1-1018-45c1-a2a0-9276d446c80en%40googlegroups.com.
signature.asc

Kumar Kaliappan

unread,
Apr 15, 2025, 5:31:06 AMApr 15
to jPOS Users
Hi team,

I have no configurations for PostChannel. Below is the code to create Channel and send the message.

final BaseChannel channel;
final ISOMsg isoRequest = new ISOMsg();
logger.info("Building channel");
channel = new PostChannel(host, port, jposPackager);
channel.setTimeout(timeout);
                channel.connect();
                channel.send(isoRequest);

I checked the chapter "5.2 SSL Channels". I dont get any clear idea how to implement it. 

Any sample code base repo or sample proram available for reference?

Regards,
Kumar

chhil

unread,
Apr 15, 2025, 10:22:33 AMApr 15
to jpos-...@googlegroups.com
jPOS is designed to work flawlessly when it is using deploy files and q2. Even if you use spring there is no need to instantiate classes directly.
You may want to search on this google group how people use it.
You really do not want to have a prod system that does a channel.connect channel.send and. channel.receive. Its only good for basic testing.

From the programmer's guide https://jpos.org/doc/proguide-draft.pdf section 5.2

<channel-adaptor name='sslclient'
class="org.jpos.q2.iso.ChannelAdaptor" logger="Q2">
<channel class="org.jpos.iso.channel.NACChannel" logger="Q2"
packager="org.jpos.iso.packager.ISO87BPackager">
<property name="host" value="127.0.0.1" />
<property name="port" value="10000" />
<property name="timeout" value="360000" />
<property name="socketFactory" value="org.jpos.iso.GenericSSLSocketFactory" />
</channel>
<in>sslsend</in>
<out>sslreceive</out>
<reconnect-delay>10000</reconnect-delay>
</channel-adaptor>

csr

unread,
Jun 10, 2025, 1:29:14 AM (8 days ago) Jun 10
to jPOS Users
Hi Team, 

I am trying to establish a TLS connection with a TLS-enabled host. I followed Section 5.2 of the JPOS Programmer’s Guide, using GenericSSLSocketFactory.
However, I encounter the error message: "Unable to connect."
When I test the same endpoint using the command:

openssl s_client -connect 127.0.0.1:9000 -cert client.crt -key client.key -CAfile ca.crt

the TLS handshake completes successfully, and the connection is established.

Could you please advise what might be wrong with my JPOS client configuration?

I am attaching the Source Code snippet and output
output.JPG

clientapp.JPG

Mark Salter

unread,
Jun 10, 2025, 1:42:23 AM (8 days ago) Jun 10
to jpos-...@googlegroups.com

Please always start a new thread instead of tacking a question on the end of an existing one.

Who or what is providing the Server you are connecting to on your local machine?

--
Mark

-- 
Mark



-------- Original Message --------
clientapp.JPG
output.JPG
signature.asc

Mark Salter

unread,
Jun 10, 2025, 1:45:05 AM (8 days ago) Jun 10
to jpos-...@googlegroups.com

P.s.  Does the  openssl command work if you use localhost instead of 127.0.0.1?

-- 
Mark



-------- Original Message --------
On 10/06/2025 06:29, csr wrote:
clientapp.JPG
output.JPG
signature.asc

Mapfunde Venon

unread,
Jun 10, 2025, 3:04:09 AM (8 days ago) Jun 10
to jpos-...@googlegroups.com
try something below 


public ISOMsg sendToSwitch(ISOMsg isoMsg) throws Exception {
try {
Logger logger = new Logger();
logger.addListener(new SimpleLogListener(System.out));
NACChannel channel = new NACChannel(serverIp, Integer.parseInt(String.valueOf(serverPort)), new YourPackager(), null);
GenericSSLSocketFactory socketFactory = new GenericSSLSocketFactory();
channel.setSocketFactory(socketFactory);
channel.setConfiguration(clientConfiguration());
((LogSource) channel).setLogger(logger, "xml-server-express");
channel.connect();
log.info("########################### Connected on channel, Ready to send.........");
channel.send(isoMsg);
var response = channel.receive();
response.dump(System.out, "");
return response;
} catch (IOException | ISOException ex) {
if (ex instanceof SocketException) {
throw new BusinessValidationException("Issuer unavailable", true);
}
log.info("########################### Failing to connect: {}", ex.getMessage());
throw new Exception(ex.getMessage());
}
}


private Configuration clientConfiguration() {
Properties props = new Properties();
props.put("keystore", "/opt/cfg/cert.jks");
props.put("storepassword", "your_password");
props.put("keypassword", "your_password");
props.put("timeout", "60000");
props.put("connect-timeout", "60000");
return new SimpleConfiguration(props);
}

Venon Mapfunde(PMP,Msc Software Engineering,Bsc Computer Science & Mathematics)
Tel:+263 775 091 262
Email:taka...@gmail.com
Skype: venon.mapfunde


csr

unread,
Jun 10, 2025, 4:50:16 AM (8 days ago) Jun 10
to jPOS Users
HI Mark,
openssl command works with both localhost and 127.0.0.1

The Server application is test SSL server written by me using javax.net.ssl.SSLServerSocketFactory

TLSServer.JPG

csr

unread,
Jun 10, 2025, 4:51:34 AM (8 days ago) Jun 10
to jPOS Users
Thanks Venon.
Let me check on this.

Mark Salter

unread,
Jun 10, 2025, 7:29:50 AM (7 days ago) Jun 10
to jpos-...@googlegroups.com

I was highlighting thingsni. The client that did not match in the openssl command that might cause the issue. 🙂

So you know the server is listening and available.

What in you Clinet runtimenis blocking it.  Where is the client running precisly, what is localhost from it's  perspective.

Can I suggest you stick with me just for now, the code shared to help is adding more variables, where I think there is a very simple problem to solve.

-- 
Mark



-------- Original Message --------
TLSServer.JPG
signature.asc

chhil

unread,
Jun 10, 2025, 8:23:56 AM (7 days ago) Jun 10
to jpos-...@googlegroups.com
Share the logs with the ssl debugging that you enabled via properties.

-chhil

Mark Salter

unread,
Jun 10, 2025, 11:14:46 AM (7 days ago) Jun 10
to jpos-...@googlegroups.com

The client is not able to hit the server's socket just yet.

I am hoping the OP shares *where* the Client is running - not directly on  localhost is my bet.

-- 
Mark



-------- Original Message --------
signature.asc

csr

unread,
Jun 10, 2025, 10:45:53 PM (7 days ago) Jun 10
to jPOS Users
Both Client and Server both are running on localhost.

regards
Satya

Andrés Alcarraz

unread,
Jun 10, 2025, 11:12:46 PM (7 days ago) Jun 10
to jpos-...@googlegroups.com
Please, share the logs, as Chill asked, otherwise it will be difficult to know what's wrong. The stack trace will point to the exact thing that failed and help us, and you find out where to look in the code.


Andrés Alcarraz

csr

unread,
Jun 11, 2025, 12:09:13 AM (7 days ago) Jun 11
to jPOS Users
Hi Andres,
We are not seeing many logs on the console. We try to enable SSL handshake debug using (-Djavax.net.debug=ssl,handshake).
Here are the console logs that we are seeing at Server and Client. Hope it gives you some information.

Server Console Log
Server-Console.JPG

Client Console Log - No debug statements print at the server side. Looks like unable to connect to server but NetConnection result shows successful.
client-console.JPG

Net Connection Result
netconnection test.JPG


when Try using openssl command to connect server -- SSL handshake successful
openssl-command.JPG

server side at last we see
Server-Openssl-console.JPG

Andrés Alcarraz

unread,
Jun 11, 2025, 12:41:39 AM (7 days ago) Jun 11
to jpos-...@googlegroups.com

Then start by configuring the log in jpos, and please, don't share text as screenshots.

----
Enviado desde mi móvil, disculpas por la brevedad.

Sent from my cellphone, I apologize for the brevity.

Andrés Alcarraz.

csr

unread,
Jun 11, 2025, 1:20:27 AM (7 days ago) Jun 11
to jPOS Users
 I found that when I disabled the setting socketfactory to the Channel it is able to connect to the server and received response,  but the connection is plain TCP connection not SSL. So looks like it is something to do the GenericSSLSocketFactory class?

disbaleSSLSocket.JPG

csr

unread,
Jun 11, 2025, 1:22:20 AM (7 days ago) Jun 11
to jPOS Users
sorry haven't seen your msg, next time I won't share the text as screenshot.

Mark Salter

unread,
Jun 11, 2025, 1:40:43 AM (7 days ago) Jun 11
to jpos-...@googlegroups.com

That client 'clear' channel code is using port 8443 and the server is listening on 9000.

Please carefully check the ports in play on both sides when you have SSL on the Client side

-- 
Mark



-------- Original Message --------
signature.asc

csr

unread,
Jun 11, 2025, 2:11:55 AM (7 days ago) Jun 11
to jPOS Users
Hi Mark,
We changed the port to 8443 from 9000. I double checked the ports correct.
After enabling the JPos logs at client side, we are seeing this error message.
Not sure why it is looking for .keystore file?

C:\projects\BCEL\jpos-vpa-ssl-client\bin>java -Djavax.net.debug=ssl,handshake JPOSSSLClient
<log realm="iso-server" at="2025-06-11T14:06:14.389317900" lifespan="12ms">
  <connect>
    Try 0 localhost:8443
      java.io.FileNotFoundException: C:\Users\satya.ch\.keystore (The system cannot find the file specified)
    Unable to connect
  </connect>
</log>
Exception in thread "main" java.io.IOException: Unable to connect
        at org.jpos.iso.BaseChannel.newSocket(BaseChannel.java:348)
        at org.jpos.iso.BaseChannel.connect(BaseChannel.java:416)
        at JPOSSSLClient.main(JPOSSSLClient.java:42)

In Client Application we set something like this.

       System.setProperty("javax.net.ssl.keyStore", "C:\\projects\\BCEL\\jpos-vpa-ssl-client\\client.p12");
        System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
        System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");

       System.setProperty("javax.net.ssl.trustStore", "C:\\projects\\BCEL\\jpos-vpa-ssl-client\\client-truststore.p12");
       System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
       System.setProperty("javax.net.ssl.trustStoreType", "PKCS12");

 VAPChannel channel = new VAPChannel("localhost", 8443, new GenericPackager("base1.xml"));
        channel.setLogger (logger, "iso-server");
        channel.setSocketFactory(new GenericSSLSocketFactory());
        channel.connect();

Mark Salter

unread,
Jun 11, 2025, 2:15:19 AM (7 days ago) Jun 11
to jpos-...@googlegroups.com

Why is it still using port 8443.

Time to stop and very carefully check what you are doing.

Start a new thread *if* you need help once you have checked everything and pose a smart question.

-- 
Mark



-------- Original Message --------
signature.asc

chhil

unread,
Jun 11, 2025, 6:02:57 AM (6 days ago) Jun 11
to jpos-...@googlegroups.com

Are your system properties being intialized before the jpos call? Probably not and its using the default home directory to find the key store.

Try the commandline argument way

java ^
 -Djavax.net.ssl.keyStore="C:\projects\BCEL\jpos-vpa-ssl-client\client.p12" ^
 -Djavax.net.ssl.keyStorePassword="changeit" ^
 -Djavax.net.ssl.keyStoreType="PKCS12" ^
 -Djavax.net.ssl.trustStore="C:\projects\BCEL\jpos-vpa-ssl-client\client-truststore.p12" ^
 -Djavax.net.ssl.trustStorePassword="changeit" ^
 -Djavax.net.ssl.trustStoreType="PKCS12" ^
 -Djavax.net.debug=ssl,handshake ^
 JPOSSSLClient

-chhil


Reply all
Reply to author
Forward
0 new messages