encode() with private key in “AndroidKeyStore” return null

做~自己de王妃 提交于 2019-12-01 06:16:38

The Android KeyChain API prevents you from being able to get an encoded private key.

See the method at line 158 of OpenSSLRSAPrivateKey.java

@Override
public final BigInteger getPrivateExponent() {
    if (key.isEngineBased()) {
        throw new UnsupportedOperationException("private exponent cannot be extracted");
    }

But the benefit of using the KeyChain API is that it provides system-wide credential storage. Any app should be able to retrieve the key pair and certificate by its alias. Refer to the KeyStore docs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!