applet签名实录
首先,确保keystore中存在一个私钥证书E:\security\testapplet>jar cfv Testapplet.jar Testapplet.class
标明清单(manifest)
增加:Testapplet.class(读入= 1175) (写出= 708)(压缩了 39%)E:\security\testapplet>jar tfv Testapplet.jar
     0 Thu Jul 31 14:08:24 CST 2003 META-INF/
    71 Thu Jul 31 14:08:24 CST 2003 META-INF/MANIFEST.MF
  1175 Thu Jul 31 14:07:26 CST 2003 Testapplet.classE:\security\testapplet>jarsigner -storetype PKCS12 Testapplet.jar Eric
Enter Passphrase for keystore: 123456E:\security\testapplet>jarsigner -verify -verbose -certs Testapplet.jar         140 Thu Jul 31 14:09:26 CST 2003 META-INF/MANIFEST.MF
         193 Thu Jul 31 14:09:28 CST 2003 META-INF/ERIC.SF
        2402 Thu Jul 31 14:09:28 CST 2003 META-INF/ERIC.RSA
           0 Thu Jul 31 14:08:24 CST 2003 META-INF/
sm      1175 Thu Jul 31 14:07:26 CST 2003 Testapplet.class      X.509, [email protected], CN=Eric H. Echidna,L=Melbourne, O=The Legion of the Bouncy Castle, C=AU
      X.509, [email protected], OU=Bouncy Intermediate Certificate, O=The Legion of the Bouncy Castle, C=AU
      X.509, OU=Bouncy Primary Certificate, O=The Legion of the Bouncy Castle, C=AU
  s = signature was verified
  m = entry is listed in manifest
  k = at least one certificate was found in keystore
  i = at least one certificate was found in identity scopejar verified.E:\security\testapplet>htmlconverter Testapplet.htm
备份副本已经存在...E:\security\testapplet\Testapplet.htm
Java Plug-in 1.4.2 Developer Guide

解决方案 »

  1.   

    keytool -genkey -alias mykey -keystore mystorejarsigner -keystore mystore test.jar mykey
      

  2.   

    java程序:
    import java.awt.*;
    import java.applet.*;
    import java.io.*;public class Testapplet extends Applet {

    public void init() {
    }
    public String test()
    {
    String fileName=System.getProperty("user.home")+System.getProperty("file.separator")+"demo.txt";
    String s=null;
    try
    {
    FileWriter fw=new FileWriter(fileName);
    fw.write("This is some test text.");
    fw.close();
    s="success!";
    }catch(Exception exc)
    {
    System.out.println("error!");
    s="faild!";
    }
    return s;
    }
    public void paint(Graphics g) {
    g.drawString("Welcome to Java Applet!!", 50, 60 );
    g.drawString(test(),100,100);
    }
    }网页文件:
    <HTML><HEAD></HEAD>
    <BODY><CENTER>
    <APPLET code = "Testapplet.class" archive = "Testapplet.jar" width = "500" height = "300">
    </APPLET>
    </CENTER></BODY>
    </HTML>
    以上使用PLUG-IN模式IE下通过,可以参考SUN的《Java Plug-in 1.4.2 Developer Guide》