`

学会数字签名

    博客分类:
  • JAVA
阅读更多

JAVA实例:学会数字签名
数字签名

用Applet写的java小程序如果没有经过签名,那么访问客户端程序下载后会受到安全限制;怎样对java小程序签名受到很多人的关注,网上也有这些方面可供参考的文档,但都不是完整,在这里我给出一份可具体操作的文档,希望能给大家一些帮助。

场景:test.jar:内含待签名的java小程序

结果:签名后,客户端能自动下载java小程序,且java小程序能访问客户端的任何资源

步骤:

(1)将java小程序打包

jar cvf test.jar test.class

(2)生成名为chinani.store的密钥库,别名为chinani

keytool -genkey -keystore chinani.store -alias chinani

密码:123456 (根据需要自己输入)

以下根据需要输入,最后确认:y

(3)导出chinani.cer数字证书

keytool -export -keystore chinani.store -alias chinani -file chinani.cer

密码:123456 (根据需要自己输入)

(4)对test.jar文件进行签名

jarsigner -keystore chinani.store test.jar chinani

密码:123456 (根据需要自己输入)

最后写一个html文件,运行此文件即可自动下载安装运行java小程序

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<meta name="GENERATOR" content="Microsoft FrontPage 4.0">

<meta name="ProgId" content="FrontPage.Editor.Document">

<title>New Page 1</title>

</head>

<body>

<!--能自动下载jre包-->

<OBJECT

classid="clsid:CAFEEFAC-0014-0000-0000-ABCDEFFEDCBA"

WIDTH = 300 HEIGHT = 300

codebase="jinstall-1_4_0-win.cab#Version=1,4,0,0">

<PARAM NAME = CODE VALUE = "test.class" >

<PARAM NAME = ARCHIVE VALUE = "test.jar" >

<PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.4">

<PARAM NAME = "scriptable" VALUE = "false" >

</object>

</body>

</html>

http://weblog.itpub.net/bloghistory2007_8_8.html

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics