Enable HTTPS for an API operation - API Gateway (2024)

Based on HTTP and the Secure Sockets Layer (SSL) protocol, HTTPS is used to encrypt information and data to secure data transmission. HTTPS is widely used today.

API Gateway supports HTTPS-based encryption of API requests. When you configure an API operation, you can specify that the API operation supports HTTP requests, HTTPS requests, or both.

If you want an API operation to support HTTPS requests, perform the following steps:

Step 1: Make preparations

Prepare the following items:

An SSL certificate contains two files: XXXXX.key and XXXXX.pem, both of which can be opened in a text editor. The following code snippets show examples of the KEY file and the PEM file of an SSL certificate:

KEY:

-----BEGIN RSA PRIVATE KEY-----MIIEpAIBAAKCAQEA8GjIleJ7rlo86mtbwcDnUfqzTQAm4b3zZEo1aKsfAuwcvCud....-----END RSA PRIVATE KEY-----

PEM:

-----BEGIN CERTIFICATE-----MIIFtDCCBJygAwIBAgIQRgWF1j00cozRl1pZ+ultKTANBgkqhkiG9w0BAQsFADBP...-----END CERTIFICATE-----

Step 2: Bind the SSL Certificate to an API group

Log on to the API Gateway console. In the left-side navigation pane, choose Publish APIs > API Groups. On the Group List page, find the target API group and click the group name. The Group Details page appears.

In the Custom Domain Name section, bind an independent domain name to the API group.Enable HTTPS for an API operation - API Gateway (1)

After you bind the independent domain name, click Select Certificate in the SSL Certificate column. In the Select Certificate dialog box, click Create Certificate. In the Create Certificate dialog box, set relevant parameters.

  • Certificate Name: the name of the certificate. We recommend that you set an informative name for easy identification.

  • Certificate Content: the complete content of the certificate. Copy the content in the XXXXX.pem file to this field.

  • Private Key: the private key of the certificate. Copy the content in the XXXXX.key file to this field. Click OK.

Step 3: Adjust the API configuration

After you bind the SSL certificate to the API group, you can adjust the Protocol parameter that is configured for the API operation. Valid values of the Protocol parameter are HTTP, HTTPS, and WEBSOCKET. You can select one or more protocols for each API operation. We recommend that you set the Protocol parameter to HTTPS for security considerations.

Enable HTTPS for an API operation - API Gateway (2)

In the left-side navigation pane, choose OpenAPIs > APIs. On the API List page, find the target API operation and click its name. On the API Definition page, click Edit in the upper-right corner. In the wizard that appears, go to the Define API Request step.

You can set the Protocol parameter to the following values:

  • HTTP: supports only HTTP requests.

  • HTTPS: supports only HTTPS requests.

  • HTTP and HTTPS: support both HTTP and HTTPS requests.

Set the Protocol parameter to HTTPS so that the API operation supports only HTTPS requests.

Enable HTTPS for an API operation - API Gateway (2024)
Top Articles
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 5780

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.