An Application Load Balancer (ALB) Ingress supports mutual authentication, which ensures server and client security in HTTPS scenarios. This topic describes the scenarios and configuration methods of mutual authentication for ALB instances over HTTPS.
In Internet communication security, the HTTPS protocol implements data encryption and identity authentication through the SSL/TLS layer. Common core authentication modes include one-way authentication and mutual (two-way) authentication. The following table describes the two modes.
tip
We recommend that you purchase and manage certificates by using Volcano Engine Certificate Center. If you have not yet purchased a certificate, you can follow the instructions below to generate a self-signed certificate.
- The alb-ingress-controller add-on has been installed and upgraded to v0.32.0 or later. For details, see Upgrading add-ons.
Step 1: Generate a certificate
Generate a self-signed CA certificate
- Download OpenSSL from the OpenSSL website to your local environment and install it.
- Execute the following command to generate a 4096-bit private key of the CA.
- Run the following command to generate the root CA certificate using the private key of the CA.
- The expected response is that you need to provide information such as the country, region, organization name, domain, and email address.
- Complete the creation of the root CA certificate, including the private key ca.key and the certificateca.crt.
Generate a server certificate
- Run the following command to generate a 2048-bit private key for the server.
- Run the following command to use the private key of the server to generate a certificate request.
- The expected response is that you need to provide information such as the country, region, organization name, domain, and email address.
- Run the following command to use the CA certificate to issue a server certificate, with the validity period set to 365 days.
- Finish creating the server certificate, including the private key server.key and certificate server.crt.
Generate a client certificate
- Run the following command to generate a 2048-bit private key for the client.
- Run the following command to generate a client certificate request using the private key of the client.
- The expected response is that you need to provide information such as the country, region, organization name, domain, and email address.
- Run the following command to issue a client certificate using the CA certificate, with the validity period set to 365 days.
- Complete the creation of the client certificate, including the private key client.key and the certificate client.crt.
Step 2: Upload certificates
- In the ALB console, upload the certificates and keys. For details, see Managing certificates. After the certificates have been added, record the IDs of the certificates. The certificate IDs will be used in configuration later.
Step 3: Configure the ALBInstance
When you use an ALBInstance to associate with an existing ALB instance or create a new ALB instance, you can configure HTTPS mutual authentication by using fields caEnabled and caCertificates in spec.listeners. This section demonstrates how to associate with an existing ALB instance. The following is an example:
The following table describes subfields in the caEnabled and caCertificates fields of the spec.listeners.
tip
The caCertificates field can contain only a certificate source and certificate ID.
Step 4: Configure an ALB Ingress
Create an Ingress and choose an HTTPS listener. The following code provides an example:
- Run the following command to view the Ingress configuration.
- If the response is similar to the following one, the ALB Ingress has been created.
- In the left navigation bar, select Instance. On the page that appears, click the name of the target ALB instance to go to the instance details page.
- Click the Listener information tab. Click the name of the listener whose port is 443 to view the listener details. You can see that mutual authentication has been enabled for the listener.
Testing the connections to services
tip
Before verification, make sure that you have deployed backend applications and services in the cluster. This example uses the nginx image and the path /. For deployment steps, see Using ALB Ingresses for service deployment. - Run the following command to access the service by using the domain name.
- The expected response is that the service is inaccessible because the request contains no client certificate for mutual authentication.
- Run the following command to access the service with the client certificate and key.
- The expected response is that the service is accessible because the request contains a valid client certificate for mutual authentication.