Consistently receiving 'cannot verify signature'
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- java, spring-boot
- Ambito
- cryptography, payments, security
Direzione di ricerca
Start with the failing testUnseal example and the verify, verifyECV2, and unsealECV2 entry points in PaymentMethodTokenRecipient.java. Compare the ECv2 setup, recipient ID, keys, and test payload against the linked Google Pay cryptography documentation. Done means the failure is reproducible with complete test inputs and signature verification succeeds or its configuration cause is documented.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug:
https://developers.google.com/pay/api/web/guides/resources/payment-data-cryptography#using-tink
We are doing the steps mentioned in this document but consistently receiving error for signature verification. Please advise.
Error: 'cannot verify signature'
What was the expected behavior?
Expectation is the encrypted payload signature should be verified and able to unseal using the private key.
However, it fails during signature verification.
How can we reproduce the bug?
https://developers.google.com/pay/api/web/guides/resources/payment-data-cryptography#example
You will need to generate an encrypted message using the merchant id.
Sample request
{
"apiVersion": 2,
"apiVersionMinor": 0,
"allowedPaymentMethods": [
{
"type": "CARD",
"parameters": {
"allowedAuthMethods": ["PAN_ONLY", "CRYPTOGRAM_3DS"],
"allowedCardNetworks": ["VISA", "MASTERCARD"]
},
"tokenizationSpecification": {
"type": "PAYMENT_GATEWAY",
"parameters": {
"gateway": "we-are-using-gateway-name",
"gatewayMerchantId": "test"
}
}
}
],
"merchantInfo": {
"merchantId": "test",
"merchantName": "Example Merchant"
},
"transactionInfo": {
"totalPriceStatus": "ESTIMATED",
"totalPrice": 10,
"currencyCode": "AUD"
}
}
Unit test
@Test
public void testUnseal() throws Exception {
// created using Google Pay API via GPAY button in JS
// The value for "tokenizationData.token" is similar to the value in following example
// https://developers.google.com/pay/api/web/guides/resources/payment-data-cryptography#example
String encryptedMessage = "...";
PaymentMethodTokenRecipient recipient =
new PaymentMethodTokenRecipient.Builder()
.protocolVersion("ECv2")
.fetchSenderVerifyingKeysWith(GooglePaymentsPublicKeysManager.INSTANCE_TEST)
.recipientId("test") // encryptedMessage created using this merchant id
.addRecipientPrivateKey(googlePayPrivateKey)
.build();
String decryptedMessage = recipient.unseal(encryptedMessage); // Fails here
log.info("Decrypted Message: {}", decryptedMessage);
}
Do you have any debugging information?
Error stack trace
java.security.GeneralSecurityException: cannot verify signature
at com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.verify(PaymentMethodTokenRecipient.java:471)
at com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.verifyECV2(PaymentMethodTokenRecipient.java:409)
at com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.unsealECV2(PaymentMethodTokenRecipient.java:375)
at com.google.crypto.tink.apps.paymentmethodtoken.PaymentMethodTokenRecipient.unseal(PaymentMethodTokenRecipient.java:352)
What version of Tink are you using?
1.10.0
Can you tell us more about your development environment?
JDK 21
Springboot 3.2.2
Gradle wrapper 8.6
Private keys stored in AWS secrets manager which are fetched using spring.config.import
The root public key auto refresh instance is being evaluated in spring configuration during application bootup
@Configuration
@Slf4j
public class AppConfigs {
@Bean
public GooglePaymentsPublicKeysManager googlePaymentsPublicKeysManager(@Value("${spring.profiles.active}") String activeProfile) {
log.info("Initializing GooglePaymentsPublicKeysManager based on profile: '{}'", activeProfile);
return Optional.ofNullable(activeProfile)
.filter(Constants.PROD_PROFILE::equalsIgnoreCase)
.map(prod -> {
log.info("Initializing GooglePaymentsPublicKeysManager public key refresh for 'production'");
// Refresh the keys in the background for production
GooglePaymentsPublicKeysManager.INSTANCE_PRODUCTION.refreshInBackground();
return GooglePaymentsPublicKeysManager.INSTANCE_PRODUCTION;
})
.orElseGet(() -> {
log.info("Initializing GooglePaymentsPublicKeysManager public key refresh for 'test'");
// Refresh the keys in the background for test
GooglePaymentsPublicKeysManager.INSTANCE_TEST.refreshInBackground();
return GooglePaymentsPublicKeysManager.INSTANCE_TEST;
});
}
}
Is there anything else you'd like to add?
A bit stuck at the moment as we are following the steps mentioned on the document.
References
- Lingua principale
- Java
- Stelle
- 23
- Fork
- 17
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tink-crypto/tink-java-apps
-
Extend documentation on thread safetyForse di nuovo libera @willinois l’ha presa 712 giorni fa e non c’è nessuna pull request aperta. Aperta
tink-crypto/tink-java-apps#4 · 1 assegnatario ·
Tutte le issue di tink-crypto/tink-java-apps
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
a2aproject/a2a-java#1275 ·
I maintainer di solito rispondono entro 1 giorno
-
module/ftp Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ballerina-platform/ballerina-library#9476 ·
I maintainer di solito rispondono entro 1 giorno
-
[Feature] 为世界管理页面添加打开存档文件夹按钮Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
HMCL-dev/HMCL#7175 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anwilli5/coin-collection-android-US#515 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
FasterXML/jackson-databind#6398 ·
I maintainer di solito rispondono entro 1 giorno