Ana içeriğe geç

mTLS Authentication Policy

General Information​

Policy Type​

policy-auth-mtls

Endpoints​

List Policies​

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Add Policy​

POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Update Policy​

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Delete Policy​

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

List Policies​

Endpoint​

GET /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Response​

Success Response (200 OK)​

{
"status": "SUCCESS",
"resultList": [
{
"apiProxy": {
"name": "MyAPI",
"requestPolicyList": [
{
"type": "policy-auth-mtls",
"name": "mtls-auth-policy",
"description": "Authenticate clients using mTLS",
"active": true,
"validateCertificate": true,
"validateACLForIssuer": true
}
],
"responsePolicyList": [],
"errorPolicyList": []
}
}
],
"resultCount": 1
}

cURL Example​

curl -X GET \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/" \
-H "Authorization: Bearer YOUR_TOKEN"

Add Policy​

Endpoint​

POST /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body​

Full JSON Body Example - Full Validation​
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-auth-mtls",
"description": "mTLS authentication with full validation",
"active": true,
"validateCertificate": true,
"validateACLForIssuer": true
}
}
Full JSON Body Example - Certificate Validation Only​
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-auth-mtls",
"description": "mTLS authentication with certificate validation only",
"active": true,
"validateCertificate": true,
"validateACLForIssuer": false
}
}

Request Body Fields​

operationMetadata​
FieldTypeRequiredDefaultDescription
targetScopestringYes-Policy scope: ALL or ENDPOINT
targetEndpointstringNo*-Endpoint path (required if targetScope=ENDPOINT)
targetEndpointHTTPMethodstringNo*-HTTP method (required if targetScope=ENDPOINT)
targetPipelinestringYes-Pipeline: REQUEST, RESPONSE, or ERROR
deploybooleanNotrueWhether to deploy after adding policy
deployTargetEnvironmentNameListarrayNo[]List of environment names to deploy to
orderintegerNonullPolicy execution order (starts from 1)

Enum: targetScope

  • ALL - Policy applies to all endpoints
  • ENDPOINT - Policy applies only to specified endpoint

Enum: targetPipeline

  • REQUEST - Executes in request pipeline (authenticates request)
  • RESPONSE - Executes in response pipeline
  • ERROR - Executes in error pipeline

Enum: targetEndpointHTTPMethod

  • GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
policy​
FieldTypeRequiredDefaultDescription
typestringYes-Policy type: policy-auth-mtls
descriptionstringNo-Policy description
activebooleanNotrueWhether policy is active
identitySourcestringNoSUBJECT_OR_ISSUERWhich certificate name the identity is resolved from
validateCertificatebooleanNotrueValidate client certificate validity dates and intended usage
validateCertificatesIssuerbooleanNotrueValidate the presented certificate chain against the Consumer's key store
validateACLForIssuerbooleanNotrueValidate the Consumer's access permission, validity and address restrictions

Note​

  • identitySource: Determines which name on the client certificate the identity is resolved from. Allowed values:

    • SUBJECT — resolve from the client certificate's own subject CN.
    • ISSUER — resolve from the certificate's issuer CN, so all certificates signed by that authority map to a single Consumer.
    • SUBJECT_OR_ISSUER (default) — try the subject CN first, fall back to the issuer CN.

    The value must be consistent with the username of the Consumer you define, otherwise the request is rejected even when the certificate is valid. The identity is read only from the client's own certificate; names of intermediate or root certificates in the chain are never used as an identity.

  • validateCertificate: When true, validates the certificate's validity dates and verifies that it was issued for client authentication purposes.

  • validateCertificatesIssuer: When true, validates the entire certificate chain presented by the client against the trusted certificates in the key store bound to the matched Consumer. If no key store is bound to the Consumer, the request is rejected.

  • validateACLForIssuer: When true, validates the matched Consumer's access permission for this API, its validity period and any address/location restrictions.

  • All validations are enabled by default for maximum security.

  • This policy is supported only on HTTP/HTTPS API Proxies. It is not supported on gRPC or WebSocket API Proxies; if defined on either, the request fails with a 500 error instead of running the certificate checks.

Response​

Success Response (200 OK)​

{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}

cURL Example​

curl -X POST \
"https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/policies/mtls-auth-policy/" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production"],
"order": 1
},
"policy": {
"type": "policy-auth-mtls",
"description": "mTLS authentication",
"active": true,
"validateCertificate": true,
"validateACLForIssuer": true
}
}'

Update Policy​

Endpoint​

PUT /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body​

Full JSON Body Example​
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": true,
"deployTargetEnvironmentNameList": ["production", "staging"],
"order": 1
},
"policy": {
"type": "policy-auth-mtls",
"description": "Updated: mTLS authentication with enhanced certificate validation",
"active": true,
"validateCertificate": true,
"validateACLForIssuer": true
}
}

Note: Request body structure is the same as Add Policy. All fields should be provided for update.

Response​

Success Response (200 OK)​

{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": [
{
"environmentName": "production",
"success": true,
"message": "Deployment successful"
}
]
}
}

Delete Policy​

Endpoint​

DELETE /apiops/projects/{projectName}/apiProxies/{apiProxyName}/policies/{policyName}/

Request​

Headers​

HeaderValue
AuthorizationBearer {token}
Content-Typeapplication/json

Path Parameters​

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name
policyNamestringYesPolicy name

Request Body​

Full JSON Body Example​
{
"operationMetadata": {
"targetScope": "ALL",
"targetPipeline": "REQUEST",
"deploy": false
}
}

Response​

Success Response (200 OK)​

{
"status": "SUCCESS",
"deploymentResult": {
"success": true,
"deploymentResults": []
}
}

Notes and Warnings​

  • Identity Resolution:

    • identitySource selects which certificate name the identity is resolved from: SUBJECT, ISSUER or SUBJECT_OR_ISSUER (default)
    • The resolved name must match the username of an enabled Consumer in Apinizer
    • The identity is read only from the client's own certificate; intermediate and root certificate names in the chain are never used
  • Certificate Validation:

    • When validateCertificate: true, validates the certificate's validity dates and verifies it was issued for client authentication purposes
    • Certificate must be valid and not expired
  • Trust Validation:

    • When validateCertificatesIssuer: true, validates the entire chain presented by the client against the key store bound to the matched Consumer
    • A key store must be bound to the Consumer; otherwise the request is rejected
    • Runs before access control, so trust is proven before the client is considered authenticated
  • Access Control:

    • When validateACLForIssuer: true, validates the matched Consumer's access permission for this API, its validity period and address/location restrictions
    • The API must be present in the Consumer's access list
  • TLS Configuration:

    • HTTPS and mTLS must be enabled in the environment settings where the policy is applied
    • TLS must terminate on the gateway; if a load balancer or ingress terminates TLS, the client certificate does not reach the gateway
    • Client certificates must be presented during TLS handshake
  • Protocol Support:

    • Supported only on HTTP/HTTPS API Proxies
    • Not supported on gRPC or WebSocket API Proxies; if defined on either, requests fail with a 500 error rather than the normal 401 authentication failure
  • Certificate Format:

    • Supports X.509 certificates (PEM, DER formats)
    • Certificate must include public key and signature
    • Certificate chain validation requires intermediate and root CA certificates
  • Security:

    • mTLS provides strong authentication based on PKI
    • More secure than password-based authentication
    • Requires proper certificate management
  • Performance: Certificate validation adds minimal overhead to TLS handshake

  • Pipeline:

    • REQUEST pipeline validates client certificate before processing request
    • Authentication failure results in 401 Unauthorized response
  • Error Handling: Invalid or missing certificates cause authentication to fail

  • Deployment: Policy changes require deployment to take effect. Set deploy: true or deploy manually.