InvalidAlgorithmParameterException:错误的IV长度:必须为16个字节长

时间:2018-09-05 21:13:37

标签: java spring-boot cryptography

我正在将Spring Boot(Java)应用程序部署在生产环境中。它可以在我们的质量检查环境中正常运行,但是在我们的生产环境中,该应用程序会陷入无休止的启动,失败然后重新启动的循环。

我们在std.out中收到此错误,然后尝试再次重新启动:

Caused by: com.acme.security.encryptionservice.acmeSecurityException: java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long
        at com.acme.security.encryptionservice.EncryptionService.decrypt(EncryptionService.java:84)
        at com.acme.abc.commons.utils.DecryptUtil.decrypt(DecryptUtil.java:38)
        at com.acme.abc.report.sender.config.SftpConfig.orgIdSessionFactory(SftpConfig.java:116)
        at com.acme.abc.report.sender.config.SftpConfig$$EnhancerBySpringCGLIB$$2fff27ac.CGLIB$orgIdSessionFactory$1(<generated>)
        at com.acme.abc.report.sender.config.SftpConfig$$EnhancerBySpringCGLIB$$2fff27ac$$FastClassBySpringCGLIB$$868ea80c.invoke(<generated>)
        at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
        at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
        at com.acme.abc.report.sender.config.SftpConfig$$EnhancerBySpringCGLIB$$2fff27ac.orgIdSessionFactory(<generated>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
        ... 57 more Caused by: java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long
        at com.sun.crypto.provider.CipherCore.init(CipherCore.java:526)
        at com.sun.crypto.provider.AESCipher.engineInit(AESCipher.java:346)
        at javax.crypto.Cipher.implInit(Cipher.java:805)
        at javax.crypto.Cipher.chooseProvider(Cipher.java:863)
        at javax.crypto.Cipher.init(Cipher.java)

所以这是我的问题-此代码在质量检查中可以正常工作。在生产环境中应该如何解决该问题?

谢谢。

0 个答案:

没有答案