Chapter 10. Enabling mutual Transport Layer Security
You can use Red Hat OpenShift Service Mesh for your application to customize the communication security between the complex array of microservices. Mutual Transport Layer Security (mTLS) is a protocol that enables two parties to authenticate each other.
10.1. About mutual Transport Layer Security (mTLS) Copy linkLink copied to clipboard!
In OpenShift Service Mesh 3, you use the
Istio
ServiceMeshControlPlane
In OpenShift Service Mesh 3, you configure
STRICT
PeerAuthentication
DestinationRule
Review the following
Istio
PeerAuthentication-
defines the type of mTLS traffic a sidecar accepts. In
PERMISSIVEmode, both plaintext and mTLS traffic are accepted. InSTRICTmode, only mTLS traffic is allowed. DestinationRule-
configures the type of TLS traffic a sidecar sends. In
DISABLEmode, the sidecar sends plaintext. InSIMPLE,MUTUAL, andISTIO_MUTUALmodes, the sidecar establishes a TLS connection. Auto mTLS-
ensures that all inter-mesh traffic is encrypted with mTLS by default, regardless of the
PeerAuthenticationmode configuration.Auto mTLSis controlled by the global mesh configuration fieldenableAutoMtls, which is enabled by default in OpenShift Service Mesh 2 and 3. The mTLS setting operates entirely between sidecar proxies, requiring no changes to application or service code.
By default,
PeerAuthentication
PERMISSIVE
10.2. Enabling strict mTLS mode by using the namespace Copy linkLink copied to clipboard!
You can restrict workloads to accept only encrypted mTLS traffic by enabling the
STRICT
PeerAuthentication
Example PeerAuthentication policy for a namespace
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: <namespace>
spec:
mtls:
mode: STRICT
You can enable mTLS for all destination hosts in the
<namespace>
DestinationRule
MUTUAL
ISTIO_MUTUAL
auto mTLS
PeerAuthentication
STRICT
Example DestinationRule policy for a namespace
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: enable-mtls
namespace: <namespace>
spec:
host: "*.<namespace>.svc.cluster.local"
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
10.3. Enabling strict mTLS across the whole service mesh Copy linkLink copied to clipboard!
You can configure mTLS across the entire mesh by applying the
PeerAuthentication
istiod
istio-system
istiod
spec.namespace
Istio
Example PeerAuthentication policy for the whole mesh
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
Additionally, create a
DestinationRule
DestinationRule
Example DestinationRule policy for the whole mesh
apiVersion: networking.istio.io/v1
kind: DestinationRule
metadata:
name: api-server
namespace: istio-system
spec:
host: kubernetes.default.svc.cluster.local
trafficPolicy:
tls:
mode: DISABLE
10.4. Validating encryptions with Kiali Copy linkLink copied to clipboard!
The Kiali console offers several ways to validate whether or not your applications, services, and workloads have Mutual Transport Layer Security (mTLS) encryption enabled.
The Services Detail Overview page displays a Security icon on the graph edges where at least one request with mTLS enabled is present. Also note that Kiali displays a lock icon in the Network section next to ports that are configured for mTLS.