- On the receiving side, grant access to the incoming applet by modifying Java's security policy.
- On the sending side, have the applet seek access permission from the receiver via signed certificates.
Method 1 requires modifying the java.policy file in jre/lib/security by adding the following lines:
grant codeBase "http://your.url.here" {
permission java.security.AllPermission;
}
As a word of caution, dropping the "codeBase" qualifier grants all applets all permission and is not advisable.
Seeking Applet Access Via Signed Certificate
Method 2 requires creating a trusted certificate and signing the applet.
- Write, compile and jar your applet as you normally does.
- Use keytool to generate private/public key pairs. This also creates a self-signed certificate.
keytool -genkey -alias alias-keystore keystore -keypass keypass -dname cn=xxxx -storepass storepass
This generates a private/public key pair stored in the keystoreprotected by storepass . Use the alias and the keypass to access the private key of this generated pair.
- This step is optional if you are signing your applet with a self-signed certificate.
If you are publishing your applet to the Internet, generate a certificate request (CSR), submit it to a certificate authority (CA) and get a CA-signed trusted certificate back. Replace the self-signed certificate with this trusted certificate.
keytool -certreq -aliasalias -keystore keystore -keypass keypass -storepass storepass
keytool -import -aliasalias -file trustedCert .cer -keystore keystore -storepass storepass
Sign your applet: jarsigner
jarsigner -keystoreReferencekeystore -storepass storepass -keypass keypass -signedjar YourSignedApplet.jar
- keytool - Key and Certificate Management Tool, Sun.
- Larry Siden, Signed Applet Tutorial.
- Chapter 10: Signed Applets, SDN tutorials, 1994-2009.
- How to Create a Self-signed SSL Certificate.
- Thawte Code Signing Certificates Enrollment Page.
- Verisign Certificate Center Purchase Page.
- Java SE Security, Sun.
- Lesson: API and Tools Use for Secure Code and File Exchanges, The Java Tutorials, Sun.
- Certificate, Java Glossary.
- Chris W. Johnson, Java Certificate Parsing, 5/18/2004.
- EJBCA User Guide.
- CertificateFactory, Java 6 Javadoc, Sun.
No comments:
Post a Comment