Modifier and Type | Field and Description |
---|---|
static String |
TYPE_JCEKS
JCEKS(Java Cryptography Extension Key Store)
|
static String |
TYPE_JKS
Java密钥库(Java Key Store,JKS)KEY_STORE,Java 平台特有的密钥库格式
JKS 密钥库可以用 Java 的 keytool 工具进行管理。 |
static String |
TYPE_PKCS12
PKCS12是公钥加密标准,它规定了可包含所有私钥、公钥和证书。
|
Constructor and Description |
---|
KeyStoreUtil() |
Modifier and Type | Method and Description |
---|---|
static KeyStore |
getKeyStore(String type)
获取
KeyStore 对象 |
static KeyStore |
readJKSKeyStore(File keyFile,
char[] password)
|
static KeyStore |
readJKSKeyStore(InputStream in,
char[] password)
|
static KeyStore |
readKeyStore(File keyFile,
char[] password)
读取KeyStore文件
KeyStore文件用于数字证书的密钥对保存 证书类型根据扩展名自动判断,规则如下:
.jks .keystore -> JKS
.p12 .pfx等其它 -> PKCS12
|
static KeyStore |
readKeyStore(String type,
File keyFile,
char[] password)
|
static KeyStore |
readKeyStore(String type,
InputStream in,
char[] password)
|
static KeyStore |
readPKCS12KeyStore(File keyFile,
char[] password)
读取PKCS12 KeyStore文件
KeyStore文件用于数字证书的密钥对保存 |
static KeyStore |
readPKCS12KeyStore(InputStream in,
char[] password)
读取PKCS12 KeyStore文件
KeyStore文件用于数字证书的密钥对保存 |
public static final String TYPE_JKS
public static final String TYPE_JCEKS
public static final String TYPE_PKCS12
public static KeyStore readJKSKeyStore(File keyFile, char[] password)
keyFile
- 证书文件password
- 密码KeyStore
public static KeyStore readJKSKeyStore(InputStream in, char[] password)
in
- InputStream
如果想从文件读取.keystore文件,使用 FileUtil.getInputStream(File)
读取password
- 密码KeyStore
public static KeyStore readPKCS12KeyStore(File keyFile, char[] password)
keyFile
- 证书文件password
- 密码KeyStore
public static KeyStore readPKCS12KeyStore(InputStream in, char[] password)
in
- InputStream
如果想从文件读取.keystore文件,使用 FileUtil.getInputStream(java.io.File)
读取password
- 密码KeyStore
public static KeyStore readKeyStore(File keyFile, char[] password)
.jks .keystore -> JKS
.p12 .pfx等其它 -> PKCS12
keyFile
- 证书文件password
- 密码,null表示无密码KeyStore
public static KeyStore readKeyStore(String type, File keyFile, char[] password)
type
- 类型keyFile
- 证书文件password
- 密码,null表示无密码KeyStore
public static KeyStore readKeyStore(String type, InputStream in, char[] password)
type
- 类型in
- InputStream
如果想从文件读取.keystore文件,使用 FileUtil.getInputStream(File)
读取password
- 密码,null表示无密码KeyStore
Copyright © 2025. All rights reserved.