Upload
kolya
View
102
Download
0
Embed Size (px)
DESCRIPTION
Java 语言编程技术. J2SDK 相关命令. 安全机制. JDK1.0 提供的沙箱模型 application 被完全信任 applet 不能运行本地可执行程序 除下载它的服务器以外, applet 不能与任何一台主机通信 applet 不能读写本地文件 …… JDK1.1 中的改进 数字签名. 安全机制. 数字签名 产生共钥和私钥 制作证书 制作档案文件 给档案文件签名. 安全机制. 产生共钥和私钥 私钥 :给文件签名 公钥:身份验证 - PowerPoint PPT Presentation
Citation preview
Java 语言编程技术
J2SDK 相关命令
Java 语言编程技术 2
安全机制 JDK1.0 提供的沙箱模型
application 被完全信任applet 不能运行本地可执行程序除下载它的服务器以外, applet 不能与任何一台主机通信
applet 不能读写本地文件……
JDK1.1 中的改进数字签名
Java 语言编程技术 3
安全机制 数字签名
产生共钥和私钥制作证书制作档案文件给档案文件签名
Java 语言编程技术 4
安全机制 产生共钥和私钥
私钥 :给文件签名公钥:身份验证keytool -genkey -alias signer -keypass
abc123 -keystore mystore
制作证书keytool -export -keystore mystore -alias
signer -file signer.cer
Java 语言编程技术 5
安全机制 制作压缩文件
jar cvf test.jar test.class
给压缩文件签名jarsigner -keystore mystore -signedjar
stest.jar test.jar signer
Java 语言编程技术 6
安全机制 接收 判别证书真伪
keytool –import –alias lisi –file signer.cer –keystore lsstore
验证压缩文件 jarsigner –verify –verbose –keystore lsstore
stest.jar
Java 语言编程技术 7
jar 压缩程序
-c create new archive -t list table of contents for archive -x extract named (or all) files from
archive -u update existing archive
Usage: jar {ctxu}[vfm0M] [jar-file] [manifest-file] [-C dir] files ...
Java 语言编程技术 8
jar 压缩程序
-v generate verbose output on standard output -f specify archive file name -m include manifest information from specified
manifest file -0 store only; use no ZIP compression -M Do not create a manifest file for the entries -C change to the specified directory and include
the following file
Usage: jar {ctxu}[vfm0M] [jar-file] [manifest-file] [-C dir] files ...
Java 语言编程技术 9
jar 压缩程序 例: jar cvf classes.jar Foo.class Bar.class
jar cvfm classes.jar mymanifest -C foo/.
Java 语言编程技术 10
jar 压缩程序 安全性 减少下载时间 压缩 包封装 功能扩展
jre\lib\ext
jar cf TicTacToe.jar *.class
<applet code=TicTacToe.class
archive=TicTacToe.jar
width=200 height=100>
</applet>
Java 语言编程技术 11
一个实例——申请 SSL 证书 http 的网站支持 https 加密传输
Java 语言编程技术 12
Java 语言编程技术 13
步骤一:生成私钥keytool -genkey -alias tomcat -keyalg
RSA -keystore <your_keystore_filename>
输入你的域名等信息,或者把参数都加进来,例如:
keytool -genkey -alias tomcat -keyalg RSA -keystore myinfocentre.keystore
Java 语言编程技术 14
步骤二:生成 CSR 并提交keytool -certreq -keyalg RSA -alias
tomcat -file certreq.csr -keystore <your_keystore_filename>
例如:keytool -certreq -keyalg RSA -alias
tomcat -file certreq.csr -keystore myinfocentre.keystore
Java 语言编程技术 15
步骤三:访问认证中心网站,提交 CSR
Java 语言编程技术 16
步骤四:导入 CA 如:天威诚信中间 CA证书)keytool -import -alias root -keystore
<your_keystore_filename> -trustcacerts -file <filename_of_the_chain_certificate>
例如:keytool -import -alias root -keystore
myinfocentre.keystore -trustcacerts -file middle.cer
Java 语言编程技术 17
Java 语言编程技术 18
步骤五:导入证书 ( 收到的服务器证书 )keytool -import -alias tomcat -keystore
<your_keystore_filename> -trustcacerts -file <your_certificate_filename>
例如:keytool -import -alias tomcat -keystore
myinfocentre.keystore -trustcacerts -file server.cer
Java 语言编程技术 19
步骤六:配置证书 把文件 myinfocentre.keystore 复制到目
录 %TOMCAT_HOME%\conf\ 下 修改 conf 目录下 server.xml 文件找到以下内容去掉其注释并修改。
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8443" minProcessors="5" maxProcessors="75" enableLookups="true" acceptCount="100" debug="0" scheme="https" secure="true" useURIValidationHack="false" disableUploadTimeout="true">
Java 语言编程技术 20
<Factory className="org.apache.coyote.tomcat4.CoyoteServerSocketFactory" clientAuth="false" protocol="TLS" keystoreFile="D:/software/Java/jakarta-tomcat-4.1.27/conf/myinfocentre.keystore" keystorePass="changeit" />
</Connector>
Java 语言编程技术 21
配置完成: http 网站可以通过 https 访问