This discussion is archived
1 Reply Latest reply: Apr 19, 2013 10:54 AM by 1004237 RSS

javax.crypto.BadPaddingException: Padding length invalid: 112

997137 Newbie
Currently Being Moderated
Hi,
I got a requirement like I need to develop FTPS server in java and I should use this FTPS server in Axway Secure Transport tool.
I have developed FTPS server and have tried to connect to this server from 'Axway Secure Transport'. I have used java keytool to generate a keystore file and imported ST(Secure Transport) services certificate into that keystore file. And created a transfer site for an account in ST(Secure Transfer) and in that transfer site I have given FTPS server ip, port, username and password. I am getting "javax.net.ssl.SSLHandshakeException: SSL handshake failed" exception.

Is it the correct way to get ssl handshake?

ST Log :
Connection failure while connecting to remote host : Received fatal alert: handshake_failure

FTPS Server Log:
FTPS server is started
[ INFO] 2013-03-14 17:24:44,380 [] [] CREATED
[ INFO] 2013-03-14 17:24:44,387 [] [] OPENED
[ INFO] 2013-03-14 17:24:44,395 [] [] SENT: 220 Service ready for new user.

[ INFO] 2013-03-14 17:24:44,406 [] [] RECEIVED: AUTH TLS
[ WARN] 2013-03-14 17:24:45,901 [] [] EXCEPTION:
javax.net.ssl.SSLHandshakeException: SSL handshake failed.
at org.apache.mina.filter.ssl.SslFilter.messageReceived(SslFilter.java:426)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
at org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.net.ssl.SSLHandshakeException: Invalid padding
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1703)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:971)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:884)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:758)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at org.apache.mina.filter.ssl.SslHandler.unwrap0(SslHandler.java:645)
at org.apache.mina.filter.ssl.SslHandler.unwrapHandshake(SslHandler.java:592)
at org.apache.mina.filter.ssl.SslHandler.handshake(SslHandler.java:461)
at org.apache.mina.filter.ssl.SslHandler.messageReceived(SslHandler.java:286)
at org.apache.mina.filter.ssl.SslFilter.messageReceived(SslFilter.java:407)
... 15 more
Caused by: javax.crypto.BadPaddingException: Padding length invalid: 112
at sun.security.ssl.CipherBox.removePadding(CipherBox.java:614)
at sun.security.ssl.CipherBox.decrypt(CipherBox.java:421)
at sun.security.ssl.InputRecord.decrypt(InputRecord.java:172)
at sun.security.ssl.EngineInputRecord.decrypt(EngineInputRecord.java:257)
at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:953)
... 23 more
[ERROR] 2013-03-14 17:24:46,130 [] [] Exception caught, closing session

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points