import cn.hutool.core.codec.Base64Encoder;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.util.Enumeration;
public class ReadP12Cert
{
public static void main(String[] args)
{
//证书路径
final String KEYSTORE_FILE = "D:\\123.pfx";
//证书密码
final String KEYSTORE_PASSWORD = "111111";
try
{
//获取PKCS12密钥库
KeyStore ks = KeyStore.getInstance("PKCS12");
FileInputStream fis = new FileInputStream(KEYSTORE_FILE);
// If the keystore password is empty(""), then we have to set
// to null, otherwise it won't work!!!
char[] nPassword = null;
if ((KEYSTORE_PASSWORD == null) || KEYSTORE_PASSWORD.trim().equals(""))
java 读取.pfx证书文件公钥私钥字符串
最新推荐文章于 2024-05-25 11:56:38 发布