{
  "schema": "https://ai-atoms.com/schemas/skill-v1.json",
  "type": "skill",
  "id": "skill/mtls-configuration",
  "version": "1.0.0",
  "name": "Mtls Configuration",
  "description": "Configure mutual TLS (mTLS) for zero-trust service-to-service communication. Use when implementing zero-trust networking, certificate management, or securing internal service communication.",
  "system_prompt_fragment": "# mTLS Configuration\n\nComprehensive guide to implementing mutual TLS for zero-trust service mesh communication.\n\n## Do not use this skill when\n\n- The task is unrelated to mtls configuration\n- You need a different domain or tool outside this scope\n\n## Instructions\n\n- Clarify goals, constraints, and required inputs.\n- Apply relevant best practices and validate outcomes.\n- Provide actionable steps and verification.\n- If detailed examples are required, open `resources/implementation-playbook.md`.\n\n## Use this skill when\n\n- Implementing zero-trust networking\n- Securing service-to-service communication\n- Certificate rotation and management\n- Debugging TLS handshake issues\n- Compliance requirements (PCI-DSS, HIPAA)\n- Multi-cluster secure communication\n\n## Core Concepts\n\n### 1. mTLS Flow\n\n```\n┌─────────┐                              ┌─────────┐\n│ Service │                              │ Service │\n│    A    │                              │    B    │\n└────┬────┘                              └────┬────┘\n     │                                        │\n┌────┴────┐      TLS Handshake          ┌────┴────┐\n│  Proxy  │◄───────────────────────────►│  Proxy  │\n│(Sidecar)│  1. ClientHello             │(Sidecar)│\n│         │  2. ServerHello + Cert      │         │\n│         │  3. Client Cert             │         │\n│         │  4. Verify Both Certs       │         │\n│         │  5. Encrypted Channel       │         │\n└─────────┘                              └─────────┘\n```\n\n### 2. Certificate Hierarchy\n\n```\nRoot CA (Self-signed, long-lived)\n    │\n    ├── Intermediate CA (Cluster-level)\n    │       │\n    │       ├── Workload Cert (Service A)\n    │       └── Workload Cert (Service B)\n    │\n    └── Intermediate CA (Multi-cluster)\n            │\n            └── Cross-cluster certs\n```\n\n## Templates\n\n### Template 1: Istio mTLS (Strict Mode)\n\n```yaml\n# Enable strict mTLS mesh-wide\napiVersion: security.istio.io/v1beta1\nkind: PeerAuthentication\nmetadata:\n  name: default\n  namespace: istio-system\nspec:\n  mtls:\n    mode: STRICT\n---\n# Namespace-level override (permissive for migration)\napiVersion: security.istio.io/v1beta1\nkind: PeerAuthentication\nmetadata:\n  name: default\n  namespace: legacy-namespace\nspec:\n  mtls:\n    mode: PERMISSIVE\n---\n# Workload-specific policy\napiVersion: security.istio.io/v1beta1\nkind: PeerAuthentication\nmetadata:\n  name: payment-service\n  namespace: production\nspec:\n  selector:\n    matchLabels:\n      app: payment-service\n  mtls:\n    mode: STRICT\n  portLevelMtls:\n    8080:\n      mode: STRICT\n    9090:\n      mode: DISABLE  # Metrics port, no mTLS\n```\n\n### Template 2: Istio Destination Rule for mTLS\n\n```yaml\napiVersion: networking.istio.io/v1beta1\nkind: DestinationRule\nmetadata:\n  name: default\n  namespace: istio-system\nspec:\n  host: \"*.local\"\n  trafficPolicy:\n    tls:\n      mode: ISTIO_MUTUAL\n---\n# TLS to external service\napiVersion: networking.istio.io/v1beta1\nkind: DestinationRule\nmetadata:\n  name: external-api\nspec:\n  host: api.external.com\n  trafficPolicy:\n    tls:\n      mode: SIMPLE\n      caCertificates: /etc/certs/external-ca.pem\n---\n# Mutual TLS to external service\napiVersion: networking.istio.io/v1beta1\nkind: DestinationRule\nmetadata:\n  name: partner-api\nspec:\n  host: api.partner.com\n  trafficPolicy:\n    tls:\n      mode: MUTUAL\n      clientCertificate: /etc/certs/client.pem\n      privateKey: /etc/certs/client-key.pem\n      caCertificates: /etc/certs/partner-ca.pem\n```\n\n### Template 3: Cert-Manager with Istio\n\n```yaml\n# Install cert-manager issuer for Istio\napiVersion: cert-manager.io/v1\nkind: ClusterIssuer\nmetadata:\n  name: istio-ca\nspec:\n  ca:\n    secretName: istio-ca-secret\n---\n# Create Istio CA secret\napiVersion: v1\nkind: Secret\nmetadata:\n  name: istio-ca-secret\n  namespace: cert-manager\ntype: kubernetes.io/tls\ndata:\n  tls.crt: <base64-encoded-ca-cert>\n  tls.key: <base64-encoded-ca-key>\n---\n# Certificate for workload\napiVersion: cert-manager.io/v1\nkind: Certificate\nmetadata:\n  name: my-service-cert\n  namespace: my-namespace\nspec:\n  secretName: my-service-tls\n  duration: 24h\n  renewBefore: 8h\n  issuerRef:\n    name: istio-ca\n    kind: ClusterIssuer\n  commonName: my-service.my-namespace.svc.cluster.local\n  dnsNames:\n    - my-service\n    - my-service.my-namespace\n    - my-service.my-namespace.svc\n    - my-service.my-namespace.svc.cluster.local\n  usages:\n    - server auth\n    - client auth\n```\n\n### Template 4: SPIFFE/SPIRE Integration\n\n```yaml\n# SPIRE Server configuration\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: spire-server\n  namespace: spire\ndata:\n  server.conf: |\n    server {\n      bind_address = \"0.0.0.0\"\n      bind_port = \"8081\"\n      trust_domain = \"example.org\"\n      data_dir = \"/run/spire/data\"\n      log_level = \"INFO\"\n      ca_ttl = \"168h\"\n      default_x509_svid_ttl = \"1h\"\n    }\n\n    plugins {\n      DataStore \"sql\" {\n        plugin_data {\n          database_type = \"sqlite3\"\n          connection_string = \"/run/spire/data/datastore.sqlite3\"\n        }\n      }\n\n      NodeAttestor \"k8s_psat\" {\n        plugin_data {\n          clusters = {\n            \"demo-cluster\" = {\n              service_account_allow_list = [\"spire:spire-agent\"]\n            }\n          }\n        }\n      }\n\n      KeyManager \"memory\" {\n        plugin_data {}\n      }\n\n      UpstreamAuthority \"disk\" {\n        plugin_data {\n          key_file_path = \"/run/spire/secrets/bootstrap.key\"\n          cert_file_path = \"/run/spire/secrets/bootstrap.crt\"\n        }\n      }\n    }\n---\n# SPIRE Agent DaemonSet (abbreviated)\napiVersion: apps/v1\nkind: DaemonSet\nmetadata:\n  name: spire-agent\n  namespace: spire\nspec:\n  selector:\n    matchLabels:\n      app: spire-agent\n  template:\n    spec:\n      containers:\n        - name: spire-agent\n          image: ghcr.io/spiffe/spire-agent:1.8.0\n          volumeMounts:\n            - name: spire-agent-socket\n              mountPath: /run/spire/sockets\n      volumes:\n        - name: spire-agent-socket\n          hostPath:\n            path: /run/spire/sockets\n            type: DirectoryOrCreate\n```\n\n### Template 5: Linkerd mTLS (Automatic)\n\n```yaml\n# Linkerd enables mTLS automatically\n# Verify with:\n# linkerd viz edges deployment -n my-namespace\n\n# For external services without mTLS\napiVersion: policy.linkerd.io/v1beta1\nkind: Server\nmetadata:\n  name: external-api\n  namespace: my-namespace\nspec:\n  podSelector:\n    matchLabels:\n      app: my-app\n  port: external-api\n  proxyProtocol: HTTP/1  # or TLS for passthrough\n---\n# Skip TLS for specific port\napiVersion: v1\nkind: Service\nmetadata:\n  name: my-service\n  annotations:\n    config.linkerd.io/skip-outbound-ports: \"3306\"  # MySQL\n```\n\n## Certificate Rotation\n\n```bash\n# Istio - Check certificate expiry\nistioctl proxy-config secret deploy/my-app -o json | \\\n  jq '.dynamicActiveSecrets[0].secret.tlsCertificate.certificateChain.inlineBytes' | \\\n  tr -d '\"' | base64 -d | openssl x509 -text -noout\n\n# Force certificate rotation\nkubectl rollout restart deployment/my-app\n\n# Check Linkerd identity\nlinkerd identity -n my-namespace\n```\n\n## Debugging mTLS Issues\n\n```bash\n# Istio - Check if mTLS is enabled\nistioctl authn tls-check my-service.my-namespace.svc.cluster.local\n\n# Verify peer authentication\nkubectl get peerauthentication --all-namespaces\n\n# Check destination rules\nkubectl get destinationrule --all-namespaces\n\n# Debug TLS handshake\nistioctl proxy-config log deploy/my-app --level debug\nkubectl logs deploy/my-app -c istio-proxy | grep -i tls\n\n# Linkerd - Check mTLS status\nlinkerd viz edges deployment -n my-namespace\nlinkerd viz tap deploy/my-app --to deploy/my-backend\n```\n\n## Best Practices\n\n### Do's\n- **Start with PERMISSIVE** - Migrate gradually to STRICT\n- **Monitor certificate expiry** - Set up alerts\n- **Use short-lived certs** - 24h or less for workloads\n- **Rotate CA periodically** - Plan for CA rotation\n- **Log TLS errors** - For debugging and audit\n\n### Don'ts\n- **Don't disable mTLS** - For convenience in production\n- **Don't ignore cert expiry** - Automate rotation\n- **Don't use self-signed certs** - Use proper CA hierarchy\n- **Don't skip verification** - Verify the full chain\n\n## Resources\n\n- [Istio Security](https://istio.io/latest/docs/concepts/security/)\n- [SPIFFE/SPIRE](https://spiffe.io/)\n- [cert-manager](https://cert-manager.io/)\n- [Zero Trust Architecture (NIST)](https://www.nist.gov/publications/zero-trust-architecture)",
  "applicable_domains": [
    "other"
  ],
  "category": "other",
  "invocation": [
    "/mtls-configuration"
  ],
  "authored_by": "claudeskills.in community",
  "source_url": "https://claudeskills.in/skill/mtls-configuration",
  "provenance": {
    "source": "claudeskills.in",
    "source_url": "https://claudeskills.in/skill/mtls-configuration",
    "license": "unknown",
    "imported_at": "2026-09-03",
    "notes": "Aggregated by claudeskills.in from community GitHub lists."
  },
  "tags": [
    "claudeskills",
    "other"
  ],
  "lifecycle": "draft"
}