Android 使用密钥库证书的数字签名
Android digital signature using keystore certificate
瞄准
我开发了一个 JAVA 桌面应用程序,用于通过访问密钥库 (Windows-MY) 使用存储在 PC 中的 x509 证书对 PDF 和 XML 文件进行数字签名。我正在尝试通过访问 android 密钥库在 Android 设备 (Phone/Tablet) 中开发相同的功能。
问题
X509 证书可以存储在 USB 令牌中,也可以在设置 > 用户凭据中直接从 SD 卡安装。我认为对于 USB 令牌,制造商应该支持 android os 否则它不会显示在密钥库中。但是我在用户凭据中安装的证书呢?我不确定在这两种情况下使用哪个密钥库。
我已经尝试了以下所有密钥库,但没有成功。
KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore.getInstance("AndroidCAStore"); // returns only trusted ca certificates not the certificates in User Credentials
KeyStore.getInstance("AndroidKeyStore");
KeyStore.getInstance("BKS");
非常感谢任何帮助!
谢谢
安装在设备上的用户凭据可通过 Android KeyChain 获得,而不是 Android KeyStore
https://developer.android.com/reference/android/security/KeyChain.html
The KeyChain class provides access to private keys and their corresponding certificate chains in credential storage.
用法与Windows-MY 略有不同,因为您需要让用户请求一个别名。使用choosePrivateKeyAlias
提示用户输入签名证书和getPrivateKey
恢复密钥
瞄准
我开发了一个 JAVA 桌面应用程序,用于通过访问密钥库 (Windows-MY) 使用存储在 PC 中的 x509 证书对 PDF 和 XML 文件进行数字签名。我正在尝试通过访问 android 密钥库在 Android 设备 (Phone/Tablet) 中开发相同的功能。
问题
X509 证书可以存储在 USB 令牌中,也可以在设置 > 用户凭据中直接从 SD 卡安装。我认为对于 USB 令牌,制造商应该支持 android os 否则它不会显示在密钥库中。但是我在用户凭据中安装的证书呢?我不确定在这两种情况下使用哪个密钥库。
我已经尝试了以下所有密钥库,但没有成功。
KeyStore.getInstance(KeyStore.getDefaultType());
KeyStore.getInstance("AndroidCAStore"); // returns only trusted ca certificates not the certificates in User Credentials
KeyStore.getInstance("AndroidKeyStore");
KeyStore.getInstance("BKS");
非常感谢任何帮助!
谢谢
安装在设备上的用户凭据可通过 Android KeyChain 获得,而不是 Android KeyStore
https://developer.android.com/reference/android/security/KeyChain.html
The KeyChain class provides access to private keys and their corresponding certificate chains in credential storage.
用法与Windows-MY 略有不同,因为您需要让用户请求一个别名。使用choosePrivateKeyAlias
提示用户输入签名证书和getPrivateKey
恢复密钥