keystore

java.security.UnrecoverableKeyException: Failed to obtain information about private key

喜欢而已 提交于 2019-11-30 06:39:18
I have the following lines to get the private key from key store on Android KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore"); keyStore.load(null); // generating key pair code omitted KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) this.keyStore.getEntry("alias", null); Everything works fine except that when the OS upgrades from Android 5.1.1 to Android 6.0.1, the 3rd line will throw java.security.UnrecoverableKeyException: Failed to obtain information about private key for very first execution. But it will work fine again afterward. Now my workaround is to

Lost keystore alias but have file and password used for alias

冷暖自知 提交于 2019-11-30 06:33:42
recently I added a new alias to my keystore to sign my app. Now I lost the new generated file with the alias, but remember the password and the alias name and have an older copy the file. Is there a way to recreate the alias using this things? mah You can list the contents of your keystore with the command: keytool -list -keystore <name of keystore file> To do this, you will need to provide the keystore password (not the alias password). This will tell you the aliases in the file, which are self-contained, allowing you to sign. If you wish, you could also extract keys using other options /

tomcat doesn't deliver intermediate certificate (https)

梦想的初衷 提交于 2019-11-30 06:21:05
问题 I created a key and a csr on console, using the openssl executable. Then I sent the csr to a CA and got the certificate back. Now I want to import it into tomcat. So I created a PKCS#12 file out of my key and my certificate: openssl pkcs12 -export -in mycert.cert -inkey mykey.pem -out key_and_cert.p12 and then created a keystore containing it: keytool -importkeystore -deststorepass [password] -destkeystore keystore.jks -srckeystore key_and_cert.p12 -srcstoretype PKCS12 -srcstorepass [password

How to remove App installed trusted CA cert on uninstalling the App

天大地大妈咪最大 提交于 2019-11-30 06:11:47
I have an app that gives option to install CA cert and it gets stored in the user tab of Trusted Credentials and it works as expected. FYI (This is how I install the cert): Intent installIntent = KeyChain.createInstallIntent(); javax.security.cert.X509Certificate x509 = javax.security.cert.X509Certificate.getInstance(caRootCertBytes); installIntent.putExtra(KeyChain.EXTRA_CERTIFICATE, x509.getEncoded()); installIntent.putExtra(KeyChain.EXTRA_NAME,caRootCertName); startActivity(installIntent); If the app is uninstalled the cert remains in the Trusted credentials . I would like the cert to be

programmatically import .cer certificate into keystore

浪尽此生 提交于 2019-11-30 03:46:25
How can I import a .p12 certificate from the classpath into the java keystore? First I used the InstallCert https://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java and did some changes so the server certificate will be imported into the keystore in the java install directory. This works fine but now I want to load a certificate from my classpath. EDIT: I just use a .cer certificate, see next answer Pali The answer: InputStream certIn = ClassLoader.class.getResourceAsStream("/package/myCert.cer"); final char sep = File.separatorChar; File dir = new

Find expiration date of Android keystore

淺唱寂寞╮ 提交于 2019-11-30 03:46:04
I made a keystore a while ago for my Android apps but I can't remember how long I set the validity for. Is there a way to find out how long the keystore is good for? When you export a signed APK file from the ADT in Eclipse (assuming you are working in Eclipse), the Export Android Application dialog shows the keystore expiry date; You can use the keytool from the jdk to get certificate info. A command like this should work keytool -list -v -keystore keystore.jks -alias mydomain Replace 'keystore.jks' with your keystore name 'mydomain' with your alias name 来源: https://stackoverflow.com

Android KeyStoreException Unknown Error

孤者浪人 提交于 2019-11-30 03:45:48
问题 I am trying to decrypt encrypted text after the user is authenticated by the Android M Fingerprint API. I have been mostly trying to follow the Android Security samples, and the examples provided in the KeyGenParameterSpec documentation. I have been able to successfully encrypt the text with the public key, but when I call cipher.doFinal with a Cipher using the private key in DECRYPT_MODE , I get a KeyStoreException "Unknown error": 03-15 10:06:58.074 14702-14702/com.example.app E

Intellij IDEA - view saved password

北慕城南 提交于 2019-11-30 03:15:10
I forgot the password for my Android keystore, but it's saved in the Intellij IDEA password manager. I know the master password, so IDEA is able to auto complete the keystore password, but I can find no way to view or copy/paste the password from the text field. Is there a plugin that can do that, maybe? I've also tried to look for some logs or a shell, because I assume that behind the scenes IDEA is using the keytool utility from the SDK, so maybe I can spot the password in the command line. I've ran out of ideas. Please help. EDIT: If anyone knows where the encrypted passwords are kept, I

不同格式证书导入keystore方法

此生再无相见时 提交于 2019-11-30 01:55:37
Java 自带的 keytool 工具 是个密钥和证书管理工具。它使用户能够管理自己的公钥 / 私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户 / 服务认证自己)或数据完整性以及认证服务。它还允许用户储存他们的通信对等者的公钥(以证书形式)。 keytool 将密钥和证书储存在一个所谓的 密钥仓库( keystore ) 中。 缺省的密钥仓库实现将密钥仓库实现为一个文件 。它用口令来保护私钥。 Java KeyStore 的类型 JKS 和 JCEKS 是 Java 密钥库 (KeyStore) 的两种比较常见类型 ( 我所知道的共有 5 种, JKS, JCEKS, PKCS12, BKS , UBER) 。 JKS 的 Provider 是 SUN ,在每个版本的 JDK 中都有, JCEKS 的 Provider 是 SUNJCE , 1.4 后我们都能够直接使用它。 JCEKS 在安全级别上要比 JKS 强,使用的 Provider 是 JCEKS( 推荐 ) ,尤其在保护 KeyStore 中的私钥上(使用 TripleDes )。 PKCS#12 是公钥加密标准,它规定了可包含所有私钥、公钥和证书。其以二进制格式存储,也称为 PFX 文件,在 windows 中可以直接导入到密钥区,注意, PKCS#12 的密钥库保护密码同时也用于保护 Key 。

Cannot generate key in Android keystore

≯℡__Kan透↙ 提交于 2019-11-30 01:43:23
We are currently experiencing an issue where sometimes when a user installes our app, the app tries to access and generate a key in the keystore but the keystore throws this exception: Caused by: java.lang.IllegalStateException: could not generate key in keystore at android.security.AndroidKeyPairGenerator.generateKeyPair(AndroidKeyPairGenerator.java:100) at java.security.KeyPairGenerator$KeyPairGeneratorImpl.generateKeyPair(KeyPairGenerator.java:275) We think it has to do with the unlock pattern off the phone does not unlock the keystore, and/or a device administrator locks the keystore. This