我已经在我的应用中实现了扩展文件和应用内购买。并且应用程序发布在 beta 频道。
在测试我手动下载扩展文件以测试下面的代码时给我错误。
E/LicenseValidator: Signature verification failed.
String userId = null;
// Skip signature check for unsuccessful requests
ResponseData data = null;
Log.i(TAG, "verify responseCode : " + responseCode);
if (responseCode == LICENSED || responseCode == NOT_LICENSED ||
responseCode == LICENSED_OLD_KEY) {
// Verify signature.
Log.i(TAG, "verify signature : " + signature);
try {
Signature sig = Signature.getInstance(SIGNATURE_ALGORITHM);
sig.initVerify(publicKey);
sig.update(signedData.getBytes());
if (!sig.verify(Base64.decode(signature))) {
Log.e(TAG, "Signature verification failed.");
handleInvalidResponse();
return;
}
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
} catch (InvalidKeyException e) {
handleApplicationError(LicenseCheckerCallback.ERROR_INVALID_PUBLIC_KEY);
return;
} catch (SignatureException e) {
throw new RuntimeException(e);
} catch (Base64DecoderException e) {
Log.e(TAG, "Could not Base64-decode signature.");
handleInvalidResponse();
return;
}
signature
并且signedData
在响应中不为空或为空。并且接收responseCode
等于LICENSED
我已经使用 Google Play 控制台密钥检查了 Base64 编码的公共 RSA 密钥,它是相同的。代码sig.verify(signatureBytes)
总是返回 false。
签名验证也不适用于同一应用的应用内购买。