gpt4 book ai didi

java - 如何验证我自己的提供商(仅用于测试目的)

转载 作者:行者123 更新时间:2023-12-01 16:06:02 25 4
gpt4 key购买 nike

现在,我编写了一个新的提供程序(ESMJCE提供程序),并且我还编写了一个简单的应用程序来测试它,但我有一些这样的异常(exception)

java.lang.SecurityException: JCE cannot authenticate the provider ESMJCE
at javax.crypto.Cipher.getInstance(DashoA13*..)
at javax.crypto.Cipher.getInstance(DashoA13*..)
at testprovider.main(testprovider.java:27)
Caused by: java.util.jar.JarException: Cannot parse file:/C:/Program%20Files/Java/jre1.6.0_02/lib/ext/abc.jar
at javax.crypto.SunJCE_c.a(DashoA13*..)
at javax.crypto.SunJCE_b.b(DashoA13*..)
at javax.crypto.SunJCE_b.a(DashoA13*..)
... 3 more

这是我的源代码

import java.security.Provider;
import java.security.Security;
import javax.crypto.Cipher;
import esm.jce.provider.ESMProvider;

public class testprovider {

/
@param args
/
public static void main(String[] args) {
// TODO Auto-generated method stub
ESMProvider esmprovider = new esm.jce.provider.ESMProvider();

Security.insertProviderAt(esmprovider,2);

Provider[] temp = Security.getProviders();
for (int i= 0; i<temp.length; i++){
System.out.println("Providers: " temp[i].getName());
}
try{
Cipher cipher = Cipher.getInstance("DES", "ESMJCE");
System.out.println("Cipher: " cipher);
int blockSize= cipher.getBlockSize();
System.out.println("blockSize= " + blockSize);
}catch (Exception e){
e.printStackTrace();
}
}
}

请帮我解决这个问题

谢谢

最佳答案

实际上,您可以绕过 Sun 根证书要求,并可以自己签署提供商:Java HotSpot Cryptographic Provider signature verification issue 。当然,先看看这里:http://download.oracle.com/javase/6/docs/technotes/guides/security/crypto/HowToImplAProvider.html#Step61

关于java - 如何验证我自己的提供商(仅用于测试目的),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2578482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com