第1步 下载签名工具 Step 1: Download Signing Tools

如果您还没有签名工具,请到SUN公司网站免费下载:http://java.sun.com/j2se/,推荐下载JDK1.4.2或以上版本,支持Solaris SPARC/x86, Linux86 和 Windows 操作系统。
         If you have not already done so, download the Java 2 Software Development Kit (SDK). The latest version is available free of charge for the Solaris SPARC/x86, Linux86, and Microsoft Windows platforms from http://java.sun.com/j2se/.

您将使用签名工具中的 keytool, jar, jarsigner 来申请代码签名证书和数字签名您的代码。 
         You will be using the keytool, jar, and jarsigner to apply for your Code Signing Certificate and sign your code.

第2步 申请签名证书 Step 2: Enrollment (如果您没有证书,请联系易维信(EVTrust)申请)

(1) 生成私钥和公钥对(Keystore) Create a Keystore

使用以下命令生成私钥和公钥对: 
         To generate a public/private key pair, enter the following command, specifying a name for your keystore and an alias as well.

c:\jdk1.5\bin\keytool -genkey -keyalg rsa -keystore <keystore_filename> -alias <alias_name>

Keytool 会提示您输入私钥密码、您的姓名(Your name,填单位网址)、您的部门名称、单位名称、所在城市、所在省份和国家缩写(中国填:CN,其他国家填其缩写),单位名称一定要与证明文件上的名称 一致,部门名称(OU)可以不填。除国家缩写必须填CN外,其余都可以是英文或中文。请一定要保存好您的私钥和私钥密码。我们不会要求您提供私钥文件!
         Keytool prompts you to enter a password for your keystore, your name, organization, and address. The public/private key pair generated by keytool is saved to your keystore and will be used to sign Java Applets and applications. This key is never sent to GlobalSign and is required to sign code. GlobalSign encourages you to make a copy of the public/private key pair and store it in a safe deposit box or other secure location. If the key is lost or stolen, contact GlobalSign immediately to have it revoked.

(2) 生成证书请求文件(CSR) Generate a CSR

请使用如下命令生成证书请求文件(CSR): 
         You need to generate a Certificate Signing Request (CSR) for the enrollment process, the following command requests Keytool to create a CSR for the key pair in the keystore:

c:\jdk1.5\bin\keytool –certreq –file certreq.csr –keystore <keystore_filename> -alias <alias_name>

请把生成的certreq.csr 文件复制和粘贴到GlobalSign证书在线申请页面的CSR文本框中,或直接发给维瑞客服,请等待1-2个工作日后颁发证书。
         Copy the contents of the CSR and paste them directly into the 维瑞信 enrollment form. Open the file in a text editor that does not add extra characters (Notepad or Vi are recommended).

第3步 使用代码签名证书 Step 3: Begin Using

(1) 导入签名证书 Import GlobalSign Codesigning Certificate

一旦GlobalSign验证了您的真实身份,将会颁发证书给您。您需要到GlobalSign网站下载您的证书,请选择 PKCS #7 格式证书(PKCS #7 Certificate Chain),此证书格式含有您的证书和根证书链,Keytool要求此格式证书 ,请把证书保存到您的电脑中。
         Once GlobalSign has verified your identity, we will send a confirmation e-mail with your Sun Java Code Signing Certificate attached. Upon receipt, the attached Code Signing Certificate is saved to a file on your computer. A Code Signing Certificate is a "trust path" or "chain" back to the GlobalSign root certificate. This "trust path" allows your code to be validated on any standard JRE without installing any additional files.

请使用如下命令导入您的证书到keystore 中,这里假设您的证书名称为:cert.cer,请同时指明详细路径,一旦成功导入证书,请及时备份您的keystore文件: 
         To import your Sun Java Signing Code Signing Certificate into your keystore, enter the following code with the path correct name for your file (for example, “cert.cer”).

c:\jdk1.5\bin\keytool -import –trustcacerts –keystore <keystore_filename> -alias <alias_name> -file cert.cer

(2) 把Applet代码打包成JAR文件 Bundle Applet into a JAR File

请使用jar 把您的Java代码打包成JAR文件,此JAR文件包含了当前目录及其子目录的所有Applet文件: 
         Use jar to bundle your Applets or applications as a JAR file. This string creates a JAR file C:\TestApplet.jar. The JAR file contains all the files under the current directory and its sub-directories.

c:\jdk1.5\bin\jar cvf C:\TestApplet.jar

运行后, Jar会显示: Jar responds:

added manifest 
         adding: TestApplet.class (in = 94208) (out= 20103)(deflated 78%) 
         adding: TestHelper.class (in = 16384) (out= 779)(deflated 95%)

(3) 数字签名Applet Sign Your Applet

使用jarsigner签名您的JAR文件,最后的参数Mycert为Keystore中签名证书的别名:
         Use jarsigner to sign the JAR file with the private key you saved in your keystore.

c:\jdk1.5\bin\jarsigner C:\TestApplet.jar MyCert

(a) 会提示您输入私钥密码,请使用您在第1步设置的密码;
         At the prompt, enter the password to your keystore. 
 
         (b) 请输入.jar文件的完整路径和文件名,MyCert 就是您在生成私钥和CSR时使用的别名<alias_name>;
         In the command syntax, TestApplet represents the name and location of your JAR file. MyCert must specify the same value that you used when generating the key pair and certificate signing request (CSR).
 
         (c) Jarsigner 会生成您的代码摘要(Hash),并把此摘要和您的签名证书添加到JAR文件中。
         Jarsigner hashes your Applet or application and stores the hash in the JAR file with a copy of your Code Signing Certificate.

如果您已经有了从其他电脑上备份的Keystore文件(如:wotonecs.jks),则可以使用如下命令来签名JAR文件,最后的参数wotonecs为Keystore中签名证书的别名:

c:\jdk1.5\bin\jarsigner -keystore wotonecs.jks C:\TestApplet.jar wotonecs

(d) 使用以下命令验证已经签名的JAR文件 Verify the output of your signed JAR file.

c:\jdk1.5\bin\jarsigner -verify -verbose -certs c:\TestApplet.jar

一旦成功签名,就可以把已经签名的JAR文件放到网上供用户下载了,用户端的Java系统会显示您的签名证书信息,如果已经签名的文件被篡改或损坏,则系统会提醒用户并拒绝安装。 
         When the signed JAR file is downloaded, the Java Runtime Environment will display your certificate to the user. If the file is tampered with in any way after it has been signed, the user will be notified and given the option to refuse installation.

转载于:https://blog.51cto.com/11357156/1774590

Java代码签名证书申请和使用指南相关推荐

  1. Sectigo EV代码签名证书申请教程

    一.EV代码签名申请前提 1.单位成立时间不低于:3个月: 2.单位工商及企查查可查: 3.单位经营正常: 4.注册地址真实存在,禁止使用集中注册地址: 5.企查查登记电话或邮箱,查询结果的电话可以接 ...

  2. 代码签名证书如何申请?

    新时代的到来对于证书方面的量需求更加大了.很多人对于代码签名证书费用是不了解的,包括如何去申请这些知识都是不清楚的,那么小编带领大家一起详细的来看一下这方面的事儿. 代码签名证书申请 我们需要先下载出 ...

  3. EV代码签名证书是什么?和单位代码签名证书有何不同?

    为什么80%的码农都做不了架构师?>>>    代码签名证书由权威CA机构验证软件开发者身份后签发,让软件开发者可以使用代码签名证书,对其开发的软件代码进行数字签名,用于验证开发者身 ...

  4. 代码签名证书,让软件真正拥有姓名!

    二狗子最近遇到了一个很灵异的事件. 一个月黑风高的夜晚,雪色的 LED 灯和电脑屏幕上变动的图案共同在二狗子脸上映出一片色彩斑斓的影子.性能卓越的耳机屏蔽了一切外在杂音,只留给二狗子简单极致的:&qu ...

  5. Thawte和Comodo的代码签名证书的区别

    代码签名证书是SSL证书中专为软件开发者提供的数字认证证书,既可以对开发者的程序代码提供保护,又可以为下载者提供安全标识.Thawte和Comodo旗下都有代码签名证书,但是区别还是很大的.ssl盾小 ...

  6. 单位OV代码签名证书与EV代码签名证书有什么区别

    以下内容由SSL盾www. ssldun .com整理发布 代码签名证书由权威CA机构验证软件开发者身份后签发,让软件开发者可以使用代码签名证书,对其开发的软件代码进行数字签名,用于验证开发者身份真实 ...

  7. 微软代码签名证书使用指南

    来源:http://***/support/signcode_guide.htm 本使用指南演示怎样使用WoSign代码签名证书来给微软代码签名,Thawte和VeriSign代码签名证书也是使用相同 ...

  8. linux安装globalsign证书,Globalsign 标准型(EV型)代码签名证书提取指南

    Globalsign 标准型(EV型)代码签名证书提取指南 一.准备工作 1. 以下内容将引导您下载提取安装 2. 使用代码签名证书,要先进行提取证书的操作步骤. 3. 当您购买了代码签名证书(Saf ...

  9. 个人也可以通过维瑞申请VeriSign,Thawte 代码签名证书

    "当前越来越多的个人和个体工商户进入软件开发行业,但是以往的代码签名证书服务都是针对软件公司,从而将更多个体开发者挡在门外." 从今日起,个人也可以通过维瑞申请VeriSign,T ...

最新文章

  1. SpringMVC列表不展示数据
  2. 机器学习-特征工程中的数据预处理
  3. codematic2连接mysql失败_codematic2.rar
  4. Vue—上手实践—快速入门
  5. 如何判断对象是否存活之引用计数发
  6. springboot事务回滚源码_002 | 搭上SpringBoot事务源码分析专车
  7. 广州python平均薪资_11 月全国程序员平均工资出炉,看看的你得薪资跟上平均水平了吗。...
  8. Bootstrap HTML 编码规范之实用为王
  9. android webview 多次加载,android – 重复webview,我想在每个加载相同
  10. crontab定时任务不执行的原因
  11. mariadb忘记密码修改密码
  12. 5亿美元续命!Uber自动驾驶存亡之秋喜获丰田投资
  13. 十进制转换为二进制数、八进制数和十六进制
  14. Mysql优化(出自官方文档) - 第十二篇(优化锁操作篇)
  15. Atitti.java android反编译解决方案-----虚拟机方案
  16. Chrome崩溃重装后仍然无法打开网页的解决方案
  17. openerp 打印报表pdf中文乱码解决办法
  18. timeline java_Java Timeline.stop方法代码示例
  19. 【蓝桥杯】——七段数码管的运用
  20. [solr] solr Similarity:切换不同相似度计算方法

热门文章

  1. 解决input中输入中文过程中会触发input事件的问题
  2. tshark简单使用-wireshark
  3. Linux修改静态IP
  4. 服务器返回的14种常见HTTP状态码
  5. 简单计算器(Java实训)
  6. C++调用两次析构函数原因
  7. python123.io同一个号可以同时在不同设备登陆吗-ITech8 - 合抱之木,生于毫末;九层之台,起于累土;千里之行,始于足下!...
  8. python 配置 mitmproxy 证书
  9. rk3128 通过自带buildroot打包开发板根文件系统,重做自己的img镜像
  10. iperf 工具使用