• Java操作证书


    
    

    import java.io.FileInputStream;
    import java.security.Key;
    import java.security.KeyPair;
    import java.security.KeyStore;
    import java.security.PrivateKey;
    import java.security.PublicKey;
    import java.security.cert.Certificate;
    import java.util.Enumeration;


    public
    static void GetPrivateKey() { try{ KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType()); keystore.load(new FileInputStream("C:\\Program Files\\Java\\jre7\\bin\\xiaoyaodijun.keystore"), "7391428".toCharArray()); KeyPair keyPair = getPrivateKey2(keystore, "xiaoyaodijun.keystore", "7391428".toCharArray()); PrivateKey privateKey = keyPair.getPrivate(); System.out.println("private key = " + privateKey); }catch(Exception ex){} } public static KeyPair getPrivateKey2(KeyStore keystore, String alias, char[] password) { try { Key key=keystore.getKey(alias,password); if(key instanceof PrivateKey) { Certificate cert=keystore.getCertificate(alias); PublicKey publicKey=cert.getPublicKey(); return new KeyPair(publicKey,(PrivateKey)key); } }catch (Exception e) { } return null; }
  • 相关阅读:
    python之enumerate
    PyCharm Debug 调试
    兼容性测试方法
    mongo基本命令
    mongodb启动
    安装STF
    新家
    用数组实现的最大堆(C++)
    VS2013调用GLPK求解线性规划
    转:Java读取txt文件和写入txt文件
  • 原文地址:https://www.cnblogs.com/taisuyuanqing/p/10296488.html
Copyright © 2020-2023  润新知