--- title: PeerAuthentication description: Peer authentication configuration for workloads. location: https://istio.io/docs/reference/config/security/peer_authentication.html layout: protoc-gen-docs generator: protoc-gen-docs schema: istio.security.v1beta1.PeerAuthentication aliases: [/docs/reference/config/security/v1beta1/peer_authentication] number_of_entries: 3 ---

## PeerAuthentication

PeerAuthentication defines mutual TLS (mTLS) requirements for incoming connections.

In sidecar mode, PeerAuthentication determines whether or not mTLS is allowed or required for connections to an Envoy proxy sidecar.

In ambient mode, security is transparently enabled for a pod by the ztunnel node agent. (Traffic between proxies uses the HBONE protocol, which includes encryption with mTLS.) Because of this, `DISABLE` mode is not supported. `STRICT` mode is useful to ensure that connections that bypass the mesh are not possible.

Examples:

Policy to require mTLS traffic for all workloads under namespace `foo`:

    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: default
      namespace: foo
    spec:
      mtls:
        mode: STRICT

For mesh level, put the policy in root-namespace according to your Istio installation.

Policies to allow both mTLS and plaintext traffic for all workloads under namespace `foo`, but require mTLS for workload `finance`.

    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: default
      namespace: foo
    spec:
      mtls:
        mode: PERMISSIVE
    ---
    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: finance
      namespace: foo
    spec:
      selector:
        matchLabels:
          app: finance
      mtls:
        mode: STRICT

Policy that enables strict mTLS for all `finance` workloads, but leaves the port `8080` to plaintext. Note the port value in the `portLevelMtls` field refers to the port of the workload, not the port of the Kubernetes service.

    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: default
      namespace: foo
    spec:
      selector:
        matchLabels:
          app: finance
      mtls:
        mode: STRICT
      portLevelMtls:
        8080:
          mode: DISABLE

Policy that inherits mTLS mode from namespace (or mesh) settings, and disables mTLS for workload port `8080`.

    apiVersion: security.istio.io/v1
    kind: PeerAuthentication
    metadata:
      name: default
      namespace: foo
    spec:
      selector:
        matchLabels:
          app: finance
      mtls:
        mode: UNSET
      portLevelMtls:
        8080:
          mode: DISABLE

Field | Type | Description | Required
--- | --- | --- | ---
`selector` | `WorkloadSelector` | The selector determines the workloads to apply the PeerAuthentication on. The selector will match with workloads in the same namespace as the policy. If the policy is in the root namespace, the selector will additionally match with workloads in all namespace. If not set, the policy will be applied to all workloads in the same namespace as the policy. If it is in the root namespace, it would be applied to all workloads in the mesh. | No
`mtls` | `MutualTLS` | Mutual TLS settings for workload. If not defined, inherit from parent. | No
`portLevelMtls` | `map<uint32, MutualTLS>` | Port specific mutual TLS settings. These only apply when a workload selector is specified. The port refers to the port of the workload, not the port of the Kubernetes service. | No

## PeerAuthentication.MutualTLS

Mutual TLS settings.

Field | Type | Description | Required
--- | --- | --- | ---
`mode` | `Mode` | Defines the mTLS mode used for peer authentication. | No

## PeerAuthentication.MutualTLS.Mode

Name | Description
--- | ---
`UNSET` | Inherit from parent, if has one. Otherwise treated as `PERMISSIVE`.
`DISABLE` | Connection is not tunneled.
`PERMISSIVE` | Connection can be either plaintext or mTLS tunnel.
`STRICT` | Connection is an mTLS tunnel (TLS with client cert must be presented).