简体   繁体   中英

I am getting a invalid parameter error on a Http Post request from a java client

I am making HTTP Post requests from a pojo java application on the IBM I-series server.

    HttpResponse response = httpclient.execute(httppost);

I am getting this error back after about 3 seconds.

java.net.SocketException: A system call received a parameter that is not 
valid. (Read failed)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:127)
at java.net.SocketInputStream.read(SocketInputStream.java:182)      
at java.net.SocketInputStream.read(SocketInputStream.java:152)      
at com.ibm.jsse2.b.a(b.java:192)                                    
     at com.ibm.jsse2.b.a(b.java:168)                                     
     at com.ibm.jsse2.at.a(at.java:358)                                   
     at com.ibm.jsse2.at.i(at.java:785)                                   
     at com.ibm.jsse2.at.a(at.java:68)                                    
     at com.ibm.jsse2.at.startHandshake(at.java:520)                      
     at 
org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredS
ocket(SSLConnectionSocketFactory.java:394)                                   
     at 
org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(
SSLConnectionSocketFactory.java:353)                                         
     at 
org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.conn
ect(DefaultHttpClientConnectionOperator.java:134)                            
     at 
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.conne
ct(PoolingHttpClientConnectionManager.java:353)                              
     at 
org.apache.http.impl.execchain.MainClientExec.establishRoute(MainC
lientExec.java:380)                                                          
     at 
org.apache.http.impl.execchain.MainClientExec.execute(MainClientEx
ec.java:236)                                                                 
     at 
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.j

I have made sure we are using TLS 1.2 and java version is 1.8

Client side - code snippets -

CloseableHttpClient httpclient = 

HttpClientBuilder.create().setDefaultRequestConfig(config).build();
HttpPost httppost = new HttpPost("https://lb1.cardknox.com/gateway");

SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(null, null, null);
SSLContext.setDefault(sslContext);

HttpResponse response = httpclient.execute(httppost); 

Note: It works fine when I use it from my eclipse workbench - I only have the issue when I run this on the IBM server.

Java runtime details on the IBM server java version "1.8.0"
Java(TM) SE Runtime Environment (build pap3280sr4fp10-20170727_01(SR4 FP10))
IBM J9 VM (build 2.8, JRE 1.8.0 OS/400 ppc-32 jvmap3280sr4fp10-20170727_01 (JIT enabled, AOT enabled) J9VM - R28_20170722_0201_B357405
JIT - tr.r14.java_20170722_357405
GC - R28_20170722_0201_B357405
J9CL - 20170722_357405)
JCL - 20170726_01 based on Oracle jdk8u144-b01

IBM Websphere server use IBM JRE not Oracle JRE. Here is the quote.

The IBM implementation of SSLContext.getInstance("TLS") is different from the Oracle implementation.

Find below the link for this.

https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/sslcontext.html .

Also look into the following quotes

If you set the system property com.ibm.jsse2.overrideDefaultTLS=true and you enable either SP800-131a strict compliance (com.ibm.jsse2.sp800-131) or Suite B (com.ibm.jsse2.suiteB) system properties, only the TLS V1.2 protocol is enabled.

from the below link. https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.security.component.80.doc/security-component/jsse2Docs/matchsslcontext_tls.html

Reference Links https://www.ibm.com/support/knowledgecenter/en/SSYKE2_7.1.0/com.ibm.java.security.component.71.doc/security-component/jsse2Docs/protocols.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM