How to authenticate my own provider( only for testing purposes)
Now, I wrote a new provider (ESMJCE provider), and I also write a simple application to test it, but I have some exceptions like that
java.lang.SecurityException: JCE cannot authenticate the provider ESMJCE
at javax.crypto.开发者_如何学GoCipher.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
And here is my source code
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();
}
}
}
Please help me solve this issue
Thanks
actually you can bypass the Sun-rooted certificate requirement and can sign provider by your own: Java HotSpot Cryptographic Provider signature verification issue. And of course look here before: http://download.oracle.com/javase/6/docs/technotes/guides/security/crypto/HowToImplAProvider.html#Step61
No you can't authenticate it unless you write your own JVM. Otherwise request the JVM provider(Oracle) to sign your Jars.
精彩评论