Skip to content

AWS Lambda Function URL Error

0

Hi,

We created a AWS Lambda function that will help us to sign a request using ECDSA and secp256k1 algorithm (using Elliptic in node.js) When we tried to access the generated Function URL it gives us a Bad Gateway Status and 502 Status Code.

We need to access the URL or an Http URL that we can call in Salesforce that will give us the Signed request with a couple of requirements that needs to be met: What we need: Request Signing - An API endpoint where we can send a request to be signed with the few requirements below and guidelines and get the signature back to be able to used in Salesforce API callout to api/transactionstatus(thesegovia)

We generated Key that meets this few requirements: Use the EC algorithm, not RSA or DSA. Be at least 256 bits in length. Use a named curve. We recommend using secp256k1. And we need to sign our request following these guidelines: *The signature value is generated as follows:

  • Render the request body as JSON using UTF-8 encoding.
  • Compute the ECDSA signature of the SHA-256 hash of the rendered request body using your private key.
  • Encode the signature using DER. Many cryptography libraries will do this automatically.
  • Render the encoded signature using Base64 encoding.

API Documentation : https://docs.thesegovia.com/signatures/ Request Signatures - CAB Payment Gateway

Please note that this item is a high priority for us, we need your support as soon as possible!

Enter image description here

Thank you Cloud Orca

asked 2 years ago266 views

1 Answer
0

I understand you're facing issues with your Lambda function URL and need guidance on creating an API endpoint for request signing. Let's address your concerns:

  1. Lambda Function URL Error: The 502 Bad Gateway error you're experiencing with your Lambda function URL could be due to various reasons, such as incorrect function configuration, execution errors, or timeout issues. To troubleshoot:
  • Check your Lambda function's logs in CloudWatch for any error messages.
  • Ensure your function is properly handling the event object passed to it.
  • Verify that your function's execution role has the necessary permissions.
  • Check if your function is timing out; you may need to increase the timeout setting.
  1. API Endpoint for Request Signing: To create an API endpoint for request signing that meets your requirements, you can modify your Lambda function to:
  • Accept input parameters (the request body to be signed) via query string parameters or in the request body.
  • Implement the ECDSA signing process using the secp256k1 curve as specified.
  • Return the signature in the response.

Here's a high-level outline of how your Lambda function could work:

  1. Parse the incoming request to extract the data to be signed.
  2. Convert the data to a JSON string and encode it as UTF-8.
  3. Compute the SHA-256 hash of the encoded data.
  4. Sign the hash using ECDSA with your secp256k1 private key.
  5. Encode the signature using DER.
  6. Base64 encode the DER-encoded signature.
  7. Return the signature in the response.

To make this endpoint accessible from Salesforce, you have a few options:

  1. Use the Lambda function URL (once you've resolved the 502 error).
  2. Create an API Gateway REST API that integrates with your Lambda function.
  3. Use Amazon CloudFront with Lambda@Edge to serve your function globally.

Given the high priority of your request, I recommend focusing on fixing the Lambda function URL issue first, as it's the quickest path to having a working endpoint. If you continue to face issues, consider setting up an API Gateway, which provides additional features like request validation and API key management.

Remember to secure your endpoint appropriately, especially since it's handling sensitive cryptographic operations. Use AWS IAM roles and policies to restrict access, and consider implementing additional authentication mechanisms if needed.

For further assistance with your specific Lambda function error, you may need to provide more details about your function's code and configuration.
Sources
Lambda function URL ERRO when trying to pass data to it in a browser | AWS re:Post
Community | Enhancing security for Lambda function URLs

answered 2 years 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.