Skip to main content
This document explains the detailed usage of a specific policy. If you are using Apinizer policies for the first time or want to learn the general working principles of policies, we recommend reading the What is Policy? page first.

Overview

What is its Purpose?

  • Ensures integrity and non-repudiation by adding digital signatures to critical parts of request or response messages.
  • Standardizes and makes the signing process auditable through centralized management of secret keys.
  • Reduces maintenance costs by creating reusable signature templates in different API Proxy flows.
  • Enables dynamic adaptation of the verification side by optionally adding signature algorithm information to the message.

Working Principle

  1. Request Arrival: For each HTTP/HTTPS request arriving at the API Gateway, the source IP address of the request is identified.
  2. Policy Check: If the Digital Signature policy is active, the system checks in the following order:
    • Is a Condition defined? If so, is the condition met?
    • Is the policy active (active=true)?
    • Is a Variable being used or is Apinizer default?
  3. Digital Signature Generation: For each defined signature rule, the text in the source variable is read, signed with the selected private key/certificate and algorithm, and the output is written to the target variable with the selected encoding (Base64/Hex); if the algorithm variable is defined, it is updated simultaneously.
  4. Decision Making:
    • Match Found: If data is found in the source variable, signature is generated and placed in the target variable.
    • No Match: If source data is empty, signature is skipped, target variable is updated with empty value and flow continues.
  5. Error Handling: Customizable HTTP status code and error message are returned for requests that do not comply with the policy rule.

Features and Capabilities

Basic Features

  • Multiple Signature Definition: Provides the ability to sign different message fields with different algorithms and keys under a single policy.
  • Variable-Based Targeting: Provides flexibility for both request and response by selecting variables for the data to be signed and the field where the signature will be written.
  • Certificate/Key Integration: Secret keys or certificates are selected through Apinizer Secret Manager, revocation checks are performed automatically.
  • Active/Passive Status Control: Easily change the active or passive status of the policy (active/passive toggle). In passive mode, the policy is not applied but its configuration is preserved.
  • Condition-Based Application: Determine when the policy will be applied by creating complex conditions with Query Builder (e.g., only for specific endpoints or header values).

Advanced Features

  • Dynamic Algorithm Broadcast: The applied algorithm name can be written into the message using signatureAlgorithmVar and provides information to consumer systems.
  • Advanced Variable Management: Existing variables can be selected and updated without editing through the Variable Update Dialog.
  • Instant Key/Certificate Creation: New Crypto Key or certificate records can be created from the configuration screen, updating the policy without waiting time.
  • Export/Import Feature: Export policy configuration as a ZIP file. Import to different environments (Development, Test, Production). Version control and backup capability.
  • Policy Group and Proxy Group Support: Manage multiple policies within Policy Group. Bulk policy assignment to Proxy Groups. Centralized update and deploy operations.
  • Deploy and Versioning: Deploy policy changes to live environment. See which API Proxies use it (Policy Usage). Proxy Group and Policy Group usage reports.

Usage Scenarios

ScenarioStatusSolution (Policy Application)Expected Behavior / Result
JSON Signing in REST ResponseExternal systems want to verify response body integritysourceVar=response.content, signatureVar=response.header.X-Signature, algorithm SHA256withRSA, Base64 output, Crypto Key selectedSignature is calculated before response is sent, added to header, verification side checks the signature
Body Signing in SOAP RequestESB must sign incoming SOAP bodysourceVar=request.soap.body, signatureVar=request.soap.header.Signature, algorithm SHA1withRSA, Hex output, certificate selectedSignature is added to SOAP header, subsystems confirm message has not changed
Algorithm Notification in IoT MessageIoT gateway wants to dynamically announce signing algorithmsignatureAlgorithmVar=request.header.X-Sign-Alg is defined, algorithm SHA512withECDSAMessage is enriched with both signature and algorithm name, device works without needing updates
Multiple Field SigningMultiple JSON fields will be signed with separate keysTwo different definitions with different sourceVar and Crypto Key selectedIndependent signature is generated for each field, consumer side performs combination verification
Inter-Microservice AuthorizationSignature required for authentication in inter-service callsSignature is added to request header, works only for internal calls via ConditionMicroservice verifies that incoming request actually comes from expected service
Pre-Archival SignatureImmutability guarantee is required before documents are storedAssigned in bulk via Policy Group, sourceVar is document content, signature is written to metadata fieldEvery archived document becomes signed, providing provability in audits
(optional) Post-Data Masking SignatureTo show that masked fields have not changedRuns after masking policy, signature is applied to the same fieldIntegrity of masked data is preserved, traceable in chain

Configuring Policy Parameters

In this step, users can create a new policy or configure existing policy parameters to define access rules. The defined parameters directly affect how the policy works (e.g., which IPs will be allowed, geographical restrictions, conditional activations, etc.). This allows the policy to be customized according to organization-specific requirements while being centrally manageable.

Creating a New Digital Signature Policy

Digital Signature Policy Configuration

Configuration Steps

StepDescription / Operation
Step 1: Go to Creation Page- Go to Development → Global Settings → Global Policies → Digital Signature from the left menu.
- Click the [+ Create] button at the top right.
Step 2: Enter Basic InformationPolicy Status: Shows Active/Passive status. New policies are active by default.

Name (Required):
Example: Production_DigitalSign
- Enter a unique name, does not start with space.
- System automatically checks. Green checkmark: available. Red X: existing name.

Description:
Example: “Signs response payload with HSM key.”
- Max. 1000 characters.
- Explain the purpose of the policy.
Step 3: Create Signature DefinitionsOpen signature definition with [+ Add] button.
- sourceVar (data source to be signed): Select the variable containing the data to be signed.
- signatureVar (target where signature will be written): Select the variable where the signature will be written.
- signatureAlgorithm: Select the signature algorithm (e.g., SHA256withRSA, SHA512withECDSA).
- outputEncodingType: Select the encoding type of signature output (BASE64 or HEXADECIMAL).
- signatureAlgorithmVar (optional): Select the variable where algorithm information will be written.
Step 4: Key/Certificate SelectionIf KEY is selected:
- Select private key from Crypto Key list or create new key.

If CERTIFICATE is selected:
- Select from certificate list.
- ⚠️ Revoked certificates are marked in red, should not be used.
Step 5: Multiple Definition and Sorting (If Any)- Add additional definitions for different message sections.
- You can assign different algorithms or encodings by editing each definition.
- Remove definition with [Delete] if not needed.
Step 6: Define Condition (Optional)- Go to Condition tab.
- Conditions determine when the policy will be active.

Examples:
- Environment-based: Header = X-Environment, Operator = Equals, Value = production
- API Key-based: Header = X-API-Key, Starts With = PROD-
- Endpoint-based: Path = /api/admin/*

If no condition is defined, policy is always active

Step 7: Customize Error Message (Optional)- Go to Error Message Customization tab.
- Customize the message to be returned when access is denied.

Default:
{ "statusCode": 500, "message": "Digital Signature policy failed! Error message is: {0}" }

Custom:
{ "statusCode": 500, "errorCode": "ERR-088-CUSTOM", "message": "Signature could not be generated, please check the destination field." }
Step 8: Save- Click the [Save] button at the top right.

Checklist:
- Unique name
- Required fields filled
- At least one signature definition exists

Result:
- Policy is added to the list.
- Can be connected to APIs.
- If global policy, automatically applied.
For descriptions of Conditions and Error Message Customization panels, you can review the Conditions and Error Message Customization sections on the What is Policy? page.

Deleting the Policy

For deletion steps of this policy and operations to be applied when in use, you can refer to the Remove Policy from Flow section on the Policy Management page.

Exporting/Importing the Policy

For export (Export) and import (Import) steps of this policy, you can refer to the Export/Import page.

Connecting the Policy to API

For the process of how this policy will be connected to APIs, you can refer to the Connect Policy to API section on the Policy Management page.

Advanced Features

FeatureDescription and Steps
Dynamic Algorithm Notification- Determine the appropriate header/body variable for signatureAlgorithmVar.
- Select the variable in the signature definition.
- Enable consumer application to read this field and automatically select verification algorithm.
Revocation Tracking- Check revocation status during certificate selection.
- Avoid using if revoked certificate is selected.
- Redeploy policy with current certificate.
Multi-Layer Signature Chain- Add multiple signature definitions for the same message.
- Arrange definition order according to data dependency.
- Create chained signatures by directing target variables to different headers or body fields.

Best Practices

Things to Do and Best Practices

CategoryDescription / Recommendations
Key ManagementBad: Signing with expired certificate.
Good: Updating policy when certificate is renewed.
Best: Tracking certificate renewal dates and setting up automatic alarms.
Variable SelectionBad: Using the same variable as both source and target.
Good: Defining source and target separately.
Best: Making header/body distinction according to consumer expectation and documenting it.
Algorithm UsageBad: Randomly selecting default algorithm.
Good: Determining algorithm suitable for application requirements.
Best: Using algorithm list approved by security team.
Multiple Definition ManagementBad: Combining all fields in a single definition.
Good: Creating definitions specific to different fields.
Best: Filling description fields of definitions and referencing in audits.
Error MessagesBad: Closing default error message and leaving it empty.
Good: Providing a general error message.
Best: Defining customized message and error code that operations teams can understand.

Security Best Practices

Security AreaDescription / Warnings
Key StorageManage keys only through Secret Manager; do not export and distribute manually.
Certificate RevocationRevoked certificates are shown with red label, must not be used.
Access ControlGive policy editing authority to minimum users, perform IAM audits regularly.
LoggingRoute signature failures to security logs, analyze unusual retry attempts.
Algorithm SecurityUse weak algorithms (MD2, MD5) only if backward compatibility is required, otherwise prefer modern options.

Things to Avoid

CategoryDescription / Warnings
Empty Source FieldsWhy to avoid: Empty content does not generate signature, target variable also remains empty.
Alternative: Validate source variable beforehand or filter with Condition.
Single Key DependencyWhy to avoid: All APIs stop when key is revoked.
Alternative: Prepare second policy with backup key within Policy Group.
Untested ChangesWhy to avoid: Wrong algorithm or target variable causes error in production environment.
Alternative: Test first in Development environment with export/import.
Error Message HidingWhy to avoid: Operations teams cannot identify the problem.
Alternative: Define custom error code and descriptive message.

Performance Tips

CriterionRecommendation / Impact
Signature Definition CountRecommendation: Remove unnecessary definitions.
Impact: Each definition adds CPU cost.
Algorithm SelectionRecommendation: Consider lighter algorithms like ECDSA.
Impact: Processing time decreases, throughput increases.
Key SizeRecommendation: Use minimum key length suitable for security policies.
Impact: Keys longer than necessary increase latency.
Condition UsageRecommendation: Define Condition so policy works only for necessary requests.
Impact: Traffic is reduced, CPU load decreases.
Order ManagementRecommendation: Run policy at the latest possible stage in the flow.
Impact: Unnecessary signature generation is not performed if previous policies fail.

Frequently Asked Questions (FAQ)

CategoryQuestionAnswer
GeneralHow many different signature definitions does the policy support?There is no practical limitation; each definition can be added as a separate row, but consider performance impact.
GeneralHow should I choose between Certificate and Crypto Key?You can use certificate if it contains private key; otherwise select Crypto Key to prefer records in HSM or key vault.
TechnicalHow do I optionally share the signature algorithm?Select signatureAlgorithmVar in signature definition; policy writes algorithm name to this variable when it runs.
TechnicalDoes the policy work if message body is not JSON?Yes, data pointed by variable is signed as long as it is plain text; data format is independent of policy.
UsageDo I have to convert global policy to local copy?No, but you can customize per API by localizing; changes made globally automatically propagate.
UsageWhich logs should I examine in error cases?Look for POLICY_DIGITALSIGN error code and customized message in Policy logs; also check Gateway general logs.