Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Android P warnings #18

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.AlgorithmParameterSpec;
import java.util.Arrays;
import java.util.Calendar;
Expand Down Expand Up @@ -79,8 +81,9 @@ private KeyPair getKeyPair() throws GeneralSecurityException, IOException {
}
// Even if we just generated the key, always read it back to ensure we
// can read it successfully.
final KeyStore.PrivateKeyEntry entry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(mAlias, null);
mKeyPair = new KeyPair(entry.getCertificate().getPublicKey(), entry.getPrivateKey());
PrivateKey privateKey = (PrivateKey) keyStore.getKey(mAlias, null);
PublicKey publicKey = privateKey != null ? keyStore.getCertificate(mAlias).getPublicKey() : null;
mKeyPair = new KeyPair(publicKey, privateKey);
}
}
return mKeyPair;
Expand Down