I am using JRE7. I have signed the jar file using jarsigner. But still I get the exception
java.security.AccessControlException: access denied ("java.io.FilePermission"
"C:\Program Files\Java\jre7\lib\ext\Cert.P12" "read")
I am trying to read the Cert.P12 stored in that directory.
I generated certificate using keytool and signed the jar. When the browser prompted me i accepted the certificate. Is it because it is not a real certificate I am getting this error?
This code to read the file is an applet code.
http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html mentions that if it is signed the error will vanish. But it did not for me.
It's permissions problem, I think its not about if it is or it is not a real certificate (I don't know). Your certificate is saved at C:\Program Files...
. Make sure that you have read
permissions in that directory. Windows Parental Control is probably blocking your access to the certificate file.
For your own security, sometimes Windows blocks applications access to C:\Program Files\...
folders and it requires Administrator
privileges to access to them. Maybe, you have to set administrator privileges to your JRE in your server, running it as administrator.
Did you grant the permission to the signature you applied? A signature by itself means nothing to Java's Security Manager. You'll also need a valid certificate with which to validate the signature, and it needs to be "trusted" by the system...
If, even after signing the applet, you still get a SecurityException, try running the code as privileged code:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// perform the security-sensitive operation here
return null;
}
});