小编swl*_*wle的帖子

使用Java从MacOS X密钥库获取私钥

我正在尝试访问我的个人MacOS X钥匙串存储,以检索使用Java加密和签名某些数据的特定私钥.加密和签名部分是功能的,但我无法检索我想要的私钥.以下是我写的一些代码来介绍我的问题:

KeyStore myKeyStore;
myKeyStore = KeyStore.getInstance("KeychainStore", "Apple");
myKeyStore.load(null, null);

// Get all the aliases in a list (I thought that calling the KeyStore
// methods during the iteration was the reason why getKey wasn't responding properly!)
// ... it wasn't actually!
ArrayList<String> aliases = new ArrayList<String>();
Enumeration<String> e = myKeyStore.aliases();
while (e.hasMoreElements()) {
    aliases.add(e.nextElement());
}

for (String alias : aliases) {
    try {
        // I read on the Internet that any ASCII password is required
        // to get the …
Run Code Online (Sandbox Code Playgroud)

java macos

12
推荐指数
1
解决办法
4164
查看次数

标签 统计

java ×1

macos ×1