Service to service mtls

From RedHatProductSecurity/prodsec-skills · View interactive version

Service to service mtls is an AI agent skill from the GitHub repository RedHatProductSecurity/prodsec-skills. Enforce SPIFFE/SPIRE plus mTLS for service-to-service authentication. Use when designing, building, or reviewing authentication between services, workloads, or machines in AI systems.

How to use this skill

Skill file

SPIFFE/SPIRE + mTLS for Service-to-Service Authentication

Security Requirement

For service-to-service communication, the recommendation is to use SPIFFE/SPIRE+mTLS. This applies to all service-to-service scenarios including agent-to-agent and agent-to-MCP-server communications.

What SPIFFE/SPIRE Provides

SPIFFE ID Format

spiffe://<trust-domain>/<workload-path>

Examples:

SPIFFE ID Extraction

At the application level, extract the SPIFFE ID from the TLS certificate to authenticate and authorize the service:

from cryptography import x509

def extract_spiffe_id(peer_certificate):
    cert = x509.load_der_x509_certificate(peer_certificate)
    for ext in cert.extensions:
        if ext.oid == x509.oid.ExtensionOID.SUBJECT_ALTERNATIVE_NAME:
            san = ext.value
            for uri in san.get_values_for_type(x509.UniformResourceIdentifier):
                if uri.startswith("spiffe://"):
                    return uri
    return None

Service Mesh Integration

Service meshes (e.g., Istio/Envoy) may extract the SPIFFE ID automatically and expose it as:

This can simplify application-level integration.

Implementation Checklist

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.