如何将密钥对导入 java 中的密钥库并使密钥不可导出
How to import key pair to keystore in java and make key not exportable
我正在将密钥对(私钥和证书)添加到 java 中的 windows 密钥库。我需要使私钥不可导出。 Java 执行此操作的代码使私钥可导出。我该如何更改?
我没有找到任何可以更改的属性。 Keystore.store 方法获取 LoadStoreParameter 但它看起来像是关于为私钥设置密码。
PrivateKey privateKey=...;
Certificate certificate=...;
KeyStore keyStore = KeyStore.getInstance("Windows-MY");
keyStore.load(null);
keyStore.setKeyEntry("alias",privateKey,"".toCharArray(),new java.security.cert.Certificate[]{certificate});
对 windows 加密服务的访问由 SunMSCAPI 提供商管理。它提供了 java JCE API 和 windows 服务之间的桥梁。参见 documentation
The SunMSCAPI provider enables applications to use the standard JCA/JCE APIs to access the native cryptographic libraries, certificates stores and key containers on the Microsoft Windows platform. The SunMSCAPI provider itself does not contain cryptographic functionality, it is simply a conduit between the Java environment and the native cryptographic services on Windows.
SunMSCAPI中的WINDOWS-MY
keystore使用标准的JavaKeyStoreAPI,没有定义任何类型的"extractable" 属性,恐怕你建立不了。
我正在将密钥对(私钥和证书)添加到 java 中的 windows 密钥库。我需要使私钥不可导出。 Java 执行此操作的代码使私钥可导出。我该如何更改?
我没有找到任何可以更改的属性。 Keystore.store 方法获取 LoadStoreParameter 但它看起来像是关于为私钥设置密码。
PrivateKey privateKey=...;
Certificate certificate=...;
KeyStore keyStore = KeyStore.getInstance("Windows-MY");
keyStore.load(null);
keyStore.setKeyEntry("alias",privateKey,"".toCharArray(),new java.security.cert.Certificate[]{certificate});
对 windows 加密服务的访问由 SunMSCAPI 提供商管理。它提供了 java JCE API 和 windows 服务之间的桥梁。参见 documentation
The SunMSCAPI provider enables applications to use the standard JCA/JCE APIs to access the native cryptographic libraries, certificates stores and key containers on the Microsoft Windows platform. The SunMSCAPI provider itself does not contain cryptographic functionality, it is simply a conduit between the Java environment and the native cryptographic services on Windows.
SunMSCAPI中的WINDOWS-MY
keystore使用标准的JavaKeyStoreAPI,没有定义任何类型的"extractable" 属性,恐怕你建立不了。