This guide demonstrates configuring Istio to use a custom root certificate for enhanced security and trust in your service mesh.
This guide demonstrates how to configure Istio to use a custom root certificate for your cluster. Follow the steps below to generate your own certificate authority (CA) and integrate it with Istio for enhanced security and trust in your service mesh.
Begin by creating a directory for your certificates in the Istio root directory. In this example, we use “ca-certs”. Then navigate into the new directory:
Copy
Ask AI
mkdir ca-certscd ca-certs
Generate your root certificate by running the following command. This process creates four files:
root-ca.conf: OpenSSL configuration file used for generating the root certificate.
root-cert.csr: Certificate Signing Request (CSR) for the root certificate.
root-cert.pem: The root certificate.
root-key.pem: The private key associated with the root certificate.
Copy
Ask AI
make -f ../tools/certs/Makefile.selfsigned.mk root-ca
A sample output may look like this:
Copy
Ask AI
istiotraining@local ~/istio-1.10.3 $ mkdir ca-certsistiotraining@local ~/istio-1.10.3 $ cd ca-certs/istiotraining@local ca-certs $ make -f ../tools/certs/Makefile.selfsigned.mk root-cagenerating root-key.pemGenerating RSA private key, 4096 bit long modulus..................................................................................................................++e is 65537 (0x10001)generating root-cert.csrgenerating root-cert.pemSignature oksubject=/O=Istio/CN=Root CAGetting Private keyistiotraining@local ca-certs $ ls
Below is an alternative sample that shows all generated files:
Copy
Ask AI
mkdir ca-certscd ca-certs/make -f ./tools/certs/Makefile.selfsigned.mk root-cagenerating root-key.pemGenerating RSA private key, 4096 bit long modulus............................+++e is 65537 (0x10001)generating root-cert.csrgenerating root-cert.pemSignature oksubject=/O=Istio/CN=Root CAGetting Private keyls# Output:# root-ca.conf root-cert.csr root-cert.pem root-key.pem
It is not recommended to use the root certificate directly for workload authentication. Instead, generate intermediate certificates to enhance security and ease certificate revocation.
Generate the intermediate certificates by running the following command. This creates an intermediate Certificate Authority (CA) for your cluster under the “localcluster” directory. The following files are produced:
cluster-ca.csr: CSR for the intermediate CA.
ca-cert.pem: Certificate for the intermediate CA.
ca-chain.pem: The full certificate chain.
Intermediate input and temporary files are stored in the localcluster directory and later cleaned up.
Copy
Ask AI
make -f ./tools/certs/Makefile.selfsigned.mk localcluster-cacerts
Sample output:
Copy
Ask AI
Generating RSA private key, 4096 bit long modulus..................................................++e is 65537 (0x10001)generating localcluster/cluster-ca.csrgenerating localcluster/ca-cert.pemSignature oksubject=/O=Istio/CN=Intermediate CA/L=localclusterGetting CA Private Keygenerating localcluster/ca-chain.pemIntermediate inputs stored in localcluster/donerm localcluster/cluster-ca.csr localcluster/intermediate.confistiotraining@local ca-certs $ cd localclusteristiotraining@local localcluster $ lsa-bash: lsa: command not found
Before proceeding, remove any pre-installed Istio resources to avoid conflicts. Delete the Istio system namespace if it exists or start with a fresh cluster. For example:
Copy
Ask AI
kubectl delete namespace istio-system# Example output:# namespace "istio-system" deleted
Optionally, clean up the default namespace by navigating to the samples directory as needed:
Copy
Ask AI
cd ..cd ca-certscd .../samples/
Next, recreate the Istio system namespace and create a secret that stores all your generated certificates. For instance:
Reinstall Istio so that the certificate authority loads the certificates and keys from the secret-mounted files. Run the following command:
Copy
Ask AI
istioctl install --set profile=demo
You will see output confirming that Istio installs the core components, including Istiod, Ingress, and Egress gateways:
Copy
Ask AI
This will install the Istio 1.10.3 demo profile with ["Istio core" "Istiod" "Ingress gateways" "Egress gateways"] components into the cluster. Proceed? (y/N) y✔ Istio core installed✔ Istiod installedProcessing resources for Egress gateways, Ingress gateways. Waiting for Deployment/istio-system/istio-egressgateway, Deployment/istio-...
You can also deploy additional add-ons such as Kiali, Grafana, and Prometheus. For example:
Enforce a policy so that workloads accept only mutual TLS traffic. Ensure the Bookinfo application is running before applying the policy. After about 15 seconds, verify that the workloads are using the specified certificates:
Copy
Ask AI
kubectl exec "$(kubectl get pod -l app=details -o jsonpath='{.items[0].metadata.name}')" -c istio-proxy -- curl -s localhost:9080
The sample output below might indicate a connection refusal, which is expected until the policies are fully in place:
Copy
Ask AI
144010290259468:error:2000206f:system library:connect:Connection refused:../crypto/bio/b_sock2.c:110:144010290259468:error:2008a0c1:BIO routines:BIO_connect:error:../crypto/bio/b_sock2.c:111:command terminated with exit code 1
To further validate the configuration, retrieve and inspect the certificate chain from one of your applications (for example, the “details” application) by connecting to the “productpage” service. Because the CA certificate in this example is self-signed, you may see a warning indicating a “self-signed certificate in certificate chain”—this is expected.The certificate output (truncated for brevity) will appear similar to:
Copy
Ask AI
-----BEGIN CERTIFICATE-----MIITCCGgAwIBAgIjAPG5720SBugrMAQGCS... (truncated for brevity)-----END CERTIFICATE-----Server certificatesubject=issuer=O = Istio, CN = Intermediate CA, L = localclusterAcceptable client certificate CA namesO = Istio, CN = Root CA
These certificates can be saved as separate files if necessary. Next, verify that the root certificate used by Istio matches your specified certificate. First, dump the certificate information from your generated root certificate:
This confirms that Istio is signing workload certificates using your provided root certificate.This guide has shown how to configure a custom certificate authority within Istio and verify its proper use in your service mesh. For more in-depth information, consider exploring additional resources on Istio Security and Kubernetes Security Best Practices.