KMSInvalidSignatureException: An error occurred (KMSInvalidSignatureException) when calling the Verify operation:


I am using AWS KMS in my tool integrated with Turtle. So I am using session from turtle to call the KMS client. The KMS parameters are passed via headers to the backend. These are generated in typescript and then sent via headers to the backend in python. I see that I am getting the values, however when calling the client I see this error :- response = kms_client.verify( ..../lib/python3.8/site-packages/botocore/", line 535, in _api_call return self._make_api_call(operation_name, kwargs) File "..../lib/python3.8/site-packages/botocore/", line 980, in _make_api_call raise error_class(parsed_response, operation_name) botocore.errorfactory.KMSInvalidSignatureException: An error occurred (KMSInvalidSignatureException) when calling the Verify operation:

asked 2 months ago133 views
2 Answers

Hey, you can try this:

  1. Ensure you're using the same asymmetric KMS key and signing algorithm for both signing and verifying.
  2. Verify the message is identical (including encoding) during both operations. If hashed, ensure consistent handling.
  3. Confirm the IAM and key policies allow the Verify operation.
  4. Make sure the KMS key is active and not disabled or pending deletion.
  5. Log key ID, message, and algorithm details to spot any mismatches.

This is the correct verify syntax:

response = client.verify(

Try to validate if you are passing correctly the parameters to your client.verify().

This resources could help you:

profile picture
answered 2 months ago
  • Hi, Thanks for your response. I am using it in a similar fashion. I have a turtle integration to retrieve this session( The turtle is using us-west-2 for arn as my host is in us-west-2 but kms is in us-east-1. Hence, I am explicitly passing region as parameter. Also I have added sufficient loggers. //snipping for brevity session = get_boto3_session_from_turtle() logger.log(logging.INFO, f"session:{session}") kms_client = session.client('kms', region_name='us-east-1') logger.log(logging.INFO,f"session for region:{kms_client.meta.region_name}") message_bytes = message.encode('utf-8') logger.log(logging.INFO, f"message_bytes:{message_bytes}") logger.log(logging.INFO, 'CALLING KMS CLIENT')
    try: response = kms_client.verify( KeyId = key_id, Message = message_bytes, Signature = signature_bytes, SigningAlgorithm = algorithm, MessageType='RAW' ) #return True if the 'SignatureValid' field is present, default to False otherwise logger.log(logging.INFO, f"response:{response}") return response.get('SignatureValid', False)



Maybe you can try making a simple verify call directly from Python using hardcoded values to rule out any issues you face. Also, make sure the header is in the right format, which is what KMS expect.


answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions