博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Creating Keys Using Java Keytool
阅读量:6366 次
发布时间:2019-06-23

本文共 1908 字,大约阅读时间需要 6 分钟。

hot3.png

The Java keytool application manages a  database of keys  and certificates.Users can create their own self-authenticated certificates and public/private key pairs.

1.Create A Pair Of Keys

In the open terminal/command window, type:

keytool –genkey –alias %alias% -keystore %keystore%

  Replacing  %alias%  with a name for your pair of keys and %keystore% with a name for your keystore, then press Enter.In this example, %alias% is KeyPair_1, and %keystore% is MyPrivateKey.store.Once you have completed these steps, your keystore will be saved on the computer.  It may be saved in your Documents folder, /home folder, or on the root drive.

2.Export A Certificate

In the terminal/command window, type:

keytool –export   –alias  %alias% -file  %file% -keystore %keystore%
  Replacing 
%alias% and %keystore%
 
with the values you used previously, and %file% with the name you would like to save your certificate as.In this example, %file% is Certificate1.cert, but you should name yours something different.You will also be asked for the keystore password.It will be saved in the same location as the keystore(usually your Documents or /home folder or the root drive).

3.Import A Certificate

In the terminal/command window, type:

keytool –import   –alias  %alias%   -file  %file% -keystore %keystore%
  Where %alias%  and %keystore% are 
differen
 
t values than you used previously, and %file% is the name of the file you saved your certificate to.You will also be asked to create a password for this new keystore. 
Usually you want to import your cetificate to jre's keystore,now fllowing steps:
cd  /usr/java/jdk/jdk1.6.0_29/jre/lib/security  # cd your $java_home/jre/lib/security

then import to jre keystore:

sudo  keytool -import -alias test -file /home/guolei/client.cert -keystore cacerts

jre's keystore default password is changeit,type the password,then everything is ok.

转载于:https://my.oschina.net/xishuixixia/blog/87951

你可能感兴趣的文章
Edge 浏览器奇葩 bug:“123456”打印成“114447”
查看>>
Sirius —— 开源版的 Siri ,由 Google 支持
查看>>
《OpenGL ES应用开发实践指南:Android卷》—— 2.7 小结
查看>>
《Windows Server 2012活动目录管理实践》——第 2 章 部署第一台域控制器2.1 案例任务...
查看>>
Java Date Time 教程-时间测量
查看>>
Selector.wakeup实现注记
查看>>
《Java EE 7精粹》—— 第1章 Java EE 1.1 简介
查看>>
《Exchange Server 2013 SP1管理实践》——导读
查看>>
syslog:类Unix系统常用的log服务
查看>>
使用Annotation设计持久层
查看>>
深入实践Spring Boot2.4.1 Neo4j依赖配置
查看>>
Zen Cart 如何添加地址栏上的小图标
查看>>
SecureCrt 连接Redhat linux
查看>>
[NHibernate]持久化类(Persistent Classes)
查看>>
如何在Hive中使用Json格式数据
查看>>
linux如何恢复被删除的热文件
查看>>
Eclipse(MyEclipse) 自动补全
查看>>
Struts2中dispatcher与redirect的区别
查看>>
zabbix agentd configure
查看>>
[From OpenBSD Man Page]CARP
查看>>