nerdexam
CompTIA

CAS-005 · Question #318

An enterprise is deploying APIs that utilize a private key and a public key to ensure the connection string is protected. To connect to the API, customers must use the private key. Which of the follow

The correct answer is D. Utilize HMAC for the keys. To securely connect a REST API to a database without hard-coding connection strings, using HMAC (Hash-based Message Authentication Code) for keys provides message integrity and authenticity for API requests.

Submitted by zhang_li· Mar 6, 2026Security Engineering

Question

An enterprise is deploying APIs that utilize a private key and a public key to ensure the connection string is protected. To connect to the API, customers must use the private key. Which of the following would best secure the REST API connection to the database while preventing the use of a hard-coded string in the request string?

Options

  • AImplement a VPN for all APIs
  • BSign the key with DSA
  • CDeploy MFA for the service accounts
  • DUtilize HMAC for the keys

How the community answered

(30 responses)
  • A
    13% (4)
  • B
    7% (2)
  • C
    3% (1)
  • D
    77% (23)

Why each option

To securely connect a REST API to a database without hard-coding connection strings, using HMAC (Hash-based Message Authentication Code) for keys provides message integrity and authenticity for API requests.

AImplement a VPN for all APIs

Implementing a VPN for all APIs provides secure communication channels, but it doesn't directly address the method of authenticating API requests or preventing hard-coded strings within the application layer for database access.

BSign the key with DSA

Signing a key with DSA (Digital Signature Algorithm) provides authenticity and non-repudiation for the key itself, but HMAC is more commonly used for authenticating messages or requests in an API context to protect against tampering and unauthorized use.

CDeploy MFA for the service accounts

Deploying MFA (Multi-Factor Authentication) is for human user accounts, not typically for service accounts connecting an API to a database; API key management and message authentication are the relevant controls here.

DUtilize HMAC for the keysCorrect

HMAC (Hash-based Message Authentication Code) uses a cryptographic hash function and a secret key to generate a message authentication code. When used with API keys, it ensures the integrity and authenticity of the API requests, preventing tampering and unauthorized access without exposing the raw private key in transit, thus securing the connection to the database and avoiding hard-coded strings.

Concept tested: API security, secure key management, message authentication

Source: https://owasp.org/www-project-api-security/

Community Discussion

No community discussion yet for this question.

Full CAS-005 Practice