zoukankan      html  css  js  c++  java
  • 根据pfx文件创建PrivateKey对象


    public static PrivateKey getPrivateKeyByPfx(String pfxPath, String password) throws Exception {
    File pfxFile = new File(pfxPath);
    return getPrivateKeyByPfx(FileUtils.readFileToByteArray(pfxFile), password);
    }
    public static PrivateKey getPrivateKeyByPfx(byte[] pfxData, String password) throws Exception {
    PrivateKey privateKey = null;
    KeyStore keystore = getKeyStore(pfxData, password);
    Enumeration<String> enums = keystore.aliases();
    String keyAlias = "";
    while (enums.hasMoreElements()) {
    keyAlias = enums.nextElement();
    if (keystore.isKeyEntry(keyAlias)) {
    privateKey = (PrivateKey) keystore.getKey(keyAlias, password.toCharArray());
    }
    }
    return privateKey;
    }
    private static KeyStore getKeyStore(byte[] pfxData, String password) throws Exception {
    KeyStore keystore = KeyStore.getInstance("PKCS12");
    keystore.load(new ByteArrayInputStream(pfxData), password.toCharArray());
    return keystore;
    }
  • 相关阅读:
    团队项目——技术规格说明书
    Scrum Meeting 11.1
    Scrum Meeting 10.31
    Scrum Meeting 10.30
    Scrum Meeting 10.29
    Scrum Meeting 10.28
    Scrum Meeting 10.27
    Scrum Meeting 10.26
    团队作业Week5
    Boost C++: 数据结构---tuple
  • 原文地址:https://www.cnblogs.com/lovenannan/p/13686718.html
Copyright © 2011-2022 走看看