Java之keytool命令学习

100 篇文章 1 订阅
97 篇文章 1 订阅

Java Keytool is a key and certificate management utility. It allows users to manage their own public/private key pairs and certificates. It also allows users to cache certificates. Java Keytool stores the keys and certificates in what is called a keystore. By default the Java keystore is implemented as a file. It protects private keys with a password. A Keytool keystore contains the private key and any certificates necessary to complete a chain of trust and establish the trustworthiness of the primary certificate.

Java keytool是Java提供的一个密钥和证书管理的实用小程序,其为用户提供了自行管理自己的公、私钥对和证书的功能。其存储密钥和证书的地方我们称之为密钥库(keystore),默认情况,密钥库(keystore)是以密码保护的文件的形式存在。keytool密钥库存储了私钥以及任何需要建立安全信任连接所必须的证书。

下面我们看下其简单命令

  • 生成密钥库
keytool -genkey -alias csdn -keystore test.jks -storetype pkcs12

在这里插入图片描述

注意:如果参数storetype指定为JKS,那么会出现警告信息

Warning:
JKS 密钥库使用专用格式。建议使用 "keytool -importkeystore -srckeystore test.jks -destkeystore test.jks -deststoretype pkcs12" 迁移到行业标准格式 PKCS12。
  • 导入证书
keytool -import -file csdn.cer -keystore test.jks

在这里插入图片描述
这里,我导入的是CSDN的证书

  • 查看证书
keytool -list -keystore test.jks

注意,添加-v参数可以查看更为详细的证书信息

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值