'JKS KeyStore not available
I'm providing the keystore path but it returns exception android.system.errnoexception open failed eacces (permission denied). I've also given the read and write permissions and used android:requestLegacyExternalStorage="true".
public static String generateSignature(String data) throws Exception {
String jksFilepath = "/storage/emulated/0/key/KeyDemoo.jks";
File file=new File(jksFilepath);
try {
Log.e("TAG", "generateSignature:try ");
Log.e("TAG", "generateSignature: "+file.getPath());
InputStream fileInputStream = new FileInputStream(file.getPath());
// Loading Keystore
// System.out.println("loading keystore");
ks.load(fileInputStream, JKSPassword);
Enumeration<String> e = ks.aliases();
while (e.hasMoreElements()) {
alias = e.nextElement();
// System.out.println("Alias of the e-Token : "+ alias);
UserCert = (X509Certificate) ks.getCertificate(alias);
UserCertPubKey = (PublicKey) ks.getCertificate(alias).getPublicKey();
// System.out.println("loading Private key");
UserCertPrivKey = (PrivateKey) ks.getKey(alias, JKSPassword);
}
// Method Call to generate Signature
signature = MakeSignature(data);
return signature;
} catch (Exception e) {
e.printStackTrace();
System.out.println("generateSignature" + e.getCause());
throw new Exception();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
