Session.connect:java.security.InvalidAlgorithmParameterException:Prime大小必须是64的倍数,并且只能是256到2048(含)

时间:2015-10-19 09:10:59

标签: java

我收到此错误

  

Exceptioncom.jcraft.jsch.JSchException:Session.connect:   java.security.InvalidAlgorithmParameterException:Prime大小必须是   64的倍数,只能在256到2048(含)范围内

此应用程序在运行sun JVM时没有问题。但是当在IBM JVM上部署此应用程序war时,java.security文件包含这些条目

#
# List of providers and their preference orders (see above):
#

security.provider.1=com.ibm.jsse2.IBMJSSEProvider2
security.provider.2=com.ibm.crypto.provider.IBMJCE
security.provider.3=com.ibm.security.jgss.IBMJGSSProvider
security.provider.4=com.ibm.security.cert.IBMCertPath
security.provider.5=com.ibm.security.sasl.IBMSASL
security.provider.6=com.ibm.xml.crypto.IBMXMLCryptoProvider
security.provider.7=com.ibm.xml.enc.IBMXMLEncProvider
security.provider.8=org.apache.harmony.security.provider.PolicyProvider
security.provider.9=com.ibm.security.jgss.mech.spnego.IBMSPNEGO

及其default_local.policy文件

grant {
    permission javax.crypto.CryptoPermission "DES", 64;
    permission javax.crypto.CryptoPermission "DESede", *;
    permission javax.crypto.CryptoPermission "RC2", 128, 
                                     "javax.crypto.spec.RC2ParameterSpec", 128;
    permission javax.crypto.CryptoPermission "RC4", 128;
    permission javax.crypto.CryptoPermission "RC5", 128, 
          "javax.crypto.spec.RC5ParameterSpec", *, 12, *;
    permission javax.crypto.CryptoPermission "RSA", 2048;
    permission javax.crypto.CryptoPermission *, 128;
};

是否应将此local_policy.jar替换为无限强度策略。

1 个答案:

答案 0 :(得分:1)

问题是JSch与SUN JCE合作,我在IBM JCE中使用它。我转到ftp4j解决了这个问题。