Search code examples
javasslcurlhttpclientrhel8

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection and javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake


Im uploading a file to external api using the curl command ,

curl -iv  --cacert xxx.pem -u xx:xx -F "dataF=@/xx.csv" -F "confId=test" -x "http://xx.xx.xx.xxx:443" "https://xxxxx.com/testupload/"

getting following error in curl

*   Trying xx.xxx.x.xx...
  • TCP_NODELAY set
  • Connected to xx.xxx.x.xx (xx.xxx.x.xx) port 443 (#0)
  • allocate connect buffer!
  • Establish HTTP proxy tunnel to test.com:443
  • Server auth using Basic with user 'testuser'

CONNECT test.com:443 HTTP/1.1 Host: test.com:443 User-Agent: curl/7.61.1 Proxy-Connection: Keep-Alive

< HTTP/1.1 200 Connection Established HTTP/1.1 200 Connection Established < Proxy-Agent: Zscaler/6.1 Proxy-Agent: Zscaler/6.1 <

  • Proxy replied 200 to CONNECT request
  • CONNECT phase completed!
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: xx.pem CApath: none
  • TLSv1.2 (OUT), TLS handshake, Client hello (1):
  • OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to test.com:443
  • Closing connection 0 curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to test.com:443

Same was working before RHEL 8 Upgrade ,

Also i tried to connect using the java httpclient but ended up with same issue

javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
    at sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1570)
    at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1400)
    at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1300 ...
Caused by: java.io.EOFException: SSL peer shut down incorrectly
    at sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:167)
    at sun.security.ssl.SSLTransport.decode(SSLTransport.java:109)
    at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1392)

Couldn't figure out the Root Cause , any pointer would be really helpful .

Thanks in advance


Solution

  • Issue is with the Fire Wall , basically firewall is blocking the outgoing connection .

    Post whitelisting the ip , issue is resolved and we were able to connect to server .