Introduction

HTTP and HTTPS are the main protocols used for data transmission on the Internet. Data transferred via HTTP is not encrypted, meaning that all information, including usernames, passwords, cookies, and other sensitive data, can be potentially exposed, intercepted, or tampered with during an HTTP connection.

HTTPS, on the other hand, is an encrypted transmission protocol for websites based on the SSL protocol. HTTPS provides end-to-end data encryption, ensuring the data privacy and integrity during transmission. ZStack Cloud supports using HTTPS to log into the UI management interface and further enhance the system's security.

This tutorial is divided into UI and command-line configuration methods, detailing the procedures for using HTTPS to log into the UI interface.

UI Configuration Method

The following sections delve into the HTTPS configuration on the Cloud. In the following sections, you will learn how to:
  • Add a third-party certificate
  • Add a system self-signed certificate
  • Update certificate
  • Switch back to HTTP to log in to the UI

Add a Third-Party Certificate

In this section, you will learn how to import a third-party certificate via the UI interface.

Prerequisites

You will need the following resources or permissions to proceed with this section:
  • A latest ZStack Cloud environment.
  • A admin or platform administrator permission to configure certificates.
  • A valid certificate issued by the commercial CA.
  • Certificates and certificate chains are only supported in CRT or PEM format, and private keys are only supported in KEY or PEM format.
    Note: If your certificate does not meet the format requirements, please convert the format on your own.

Procedure

  1. Log in to ZStack Cloud.
  2. Choose Settings > System and Security > Certificate Management.
  3. On the Certificate Management page, click Add Certificate.
  4. On the Import Certificate page, set the following parameters:
    • Import Mode: Choose Third-party Certificate.
    • Certificate Document: Upload or import a certificate.
      Note:
      • Only CRT and PEM formats are supported.
      • The certificate content starts with ----BEGIN CERTIFICATE---- and ends with ----END CERTIFICATE----.
    • Private Key: Upload or import a private key.
      Note:
      • Only KEY and PEM formats are supported.
      • The private key content starts with ----BEGIN (RSAIEC) PRIVATE KEY---- and ends with ----END (RSAIEC) PRIVATE KEY----.
    • Certificate Chain: Upload or import a certificate chain.
      Note:
      • Only CRT and PEM formats are supported.
      • The certificate content starts with ----BEGIN CERTIFICATE---- and ends with ----END CERTIFICATE----.
    • HTTP Redirection: Optional. If enabled, requests are redirected by default from port 5000 of the HTTP address to port 5443 of the HTTPS address.
    Figure 1. Add Third-Party Certificate


  5. Review the configuration and click OK.
  6. After the above operations, the Cloud platform will automatically refresh and you can access the UI via the HTTPS protocol.
    Note: After configuring the certificate, the system will establish a new session, and you will need to log in to the UI interface again.

Add a System Self-Signed Certificate

In this section, you will learn how to import a system self-signed certificate via the UI interface.

Prerequisites

You will need the following resources or permissions to proceed with this section:
  • A latest ZStack Cloud environment.
  • A admin or platform administrator permission to configure certificates.

Procedure

  1. Log in to ZStack Cloud.
  2. Choose Settings > System and Security > Certificate Management.
  3. On the Certificate Management page, click Add Certificate.
  4. On the Import Certificate page, set the following parameters:
    • Import Mode: Choose System Self-signed Certificate.
    • Duration: Specify a validation duration for the system self-signed certificate. Valid values: 3 months, 1 year, 3 years, 5 years, and 10 years. By default, 10 years is selected.
    • HTTP Redirection: Optional. If enabled, requests are redirected by default from port 5000 of the HTTP address to port 5443 of the HTTPS address.
    • Custom Certificate Information: Optional. If enabled, you can customize your self-signed certificate information.
      • Common Name: Optional. Set a common name. By default, the common name is localhost.

        The input must be 1 to 64 characters in length and can contain letters, digits, and special characters. Supported special characters include ~`@#$%^&*()-_+={}[]|:;'<>.?/

      • Organization Name: Optional. Set a name for your organization. By default, the organization name is localhost.

        The input must be 1 to 64 characters in length and can contain letters, digits, and special characters. Supported special characters include ~`@#$%^&*()-_+={}[]|:;'<>.?/

      • Organization Unit Name: Optional. Set a name for your organization unit.

        The input must be 1 to 64 characters in length and can contain letters, digits, and special characters. Supported special characters include ~`@#$%^&*()-_+={}[]|:;'<>.?/

      • Country/Region Name: The country/region name can only be set as CN.
      • State/Province Name: Optional. Set the state or province name.

        The input must be 1 to 128 characters in length and can contain Chinese characters, letters, digits, and special characters. Supported special characters include ~`@#$%^&*()-_+={}[]|:;'<>.?/

      • Locality Name: Optional. Set a city name.

        The input must be 1 to 128 characters in length and can contain Chinese characters, letters, digits, and special characters. Supported special characters include ~`@#$%^&*()-_+={}[]|:;'<>.?/

      • Email Address: Optional. Set an email address.
    Figure 2. Add System Self-Signed Certificate


  5. Review the configuration and click OK.
  6. After the above operations, the Cloud platform will automatically refresh and the UI can be accessed via the HTTPS protocol.
    Note: After configuring the certificate, the system will establish a new session, and you will need to log in to the UI interface again.

Update Certificate

In this section, you will learn how to how to update a certificate via the UI interface.

Prerequisites

You will need the following resources or permissions to proceed with this section:
  • A latest ZStack Cloud environment.
  • A admin or platform administrator permission to configure certificates.
  • The added certificate has changed and requires updates.

Procedure

  1. Log in to ZStack Cloud.
  2. Choose Settings > System and Security > Certificate Management.
  3. On the Certificate Management page, click Update Certificate
    Figure 3. Update Certificate


  4. Review the configuration and click OK to update the certificate.
    Note: The system will detect the current certificate path and write the certificate information to that path when updating the certificate.

Switch back to HTTP to Log in to the UI

In this section, you will learn how to switch back to HTTP to log in to the UI .

Prerequisites

You will need the following resources or permissions to proceed with this section:
  • A latest ZStack Cloud environment.
  • A admin or platform administrator permission to configure certificates.
  • The user has configured the SSL certificate.

Procedure

  1. Log in to ZStack Cloud.
  2. Choose Settings > System and Security > Certificate Management.
  3. On the Certificate Management page, Click Switch back to HTTP.
    Figure 4. Switch Back to HTTP to Log in to the UI


  4. In the confirmation pop-up, Click OK to switch back to HTTP to login in to the UI.
    Note: The session is reestablished after you switch back to HTTP. You need to log in to the UI again. You can then log in to the UI via HTTP protocol after switching back to HTTP.

Command-line Configuration Method

The following sections will introduce the command line configuration method of HTTPS login to UI in two scenarios of single management node and multi-management node.
  • HTTPS mode is disabled by default.
  • After enabling HTTPS, the system supports port 5443 by default and you can specify other ports for login.
  • When HTTPS is enabled, if you log in to the Cloud on port 5000 using HTTP, the login page will be automatically redirected to HTTPS. Currently, only HTTP port 5000 is supported for automatic redirection to HTTPS.
  • The system supports PKCS12 format certificates by default. Currently, only PKCS12/JKS format certificate is supported. If you use certificates in other formats, please convert the format yourself.

Single Management Node Scenario

This section primarily focuses on scenarios involving a single management node and you will learn:
  • How to log in to the UI using the default HTTPS method
  • How to log in to the UI with a custom HTTPS configuration
  • How to switch back to HTTP for UI login

Log in to UI Using Default HTTPS Method

About this task

By default, the Cloud supports HTTPS login to the UI with a system default certificate.

Procedure

  1. Stop the management node service and UI service by running the following commands on the management node.
    zstack-ctl stop
  2. Make sure that the VNC console supports the HTTPS feature.
    1. Run the following command to view the certificate path and the private key password (which are both initially set to system default values).
      zstack-ctl show_ui_config
      Example:
      [root@localhost ~]# zstack-ctl show_ui_config
      db_url = jdbc:mysql://10.0.233.184:3306
      db_username = zstack_ui
      db_password = zstack.ui.password
      mn_host = 127.0.0.1
      mn_port = 8080
      webhook_host = 127.0.0.1
      webhook_port = 5000
      server_port = 5000
      log = /usr/local/zstack/apache-tomcat/logs
      enable_ssl = false
      ssl_keyalias = zstackui
      ssl_keystore = /usr/local/zstack/zstack-ui/ui.keystore.p12 //certificate path
      ssl_keystore_type = PKCS12
      ssl_keystore_password = password //private key password
    2. By default, the UI supports PKCS12 formatted certificates, whereas the VNC console proxy supports x509 formatted certificates. If you want to use the UI certificate for the VNC console proxy as well, you need to convert the PKCS12 formatted certificate into x509 format.
      openssl pkcs12 -in /path/to/mykeystore.p12 -out ui.keystore.pem -nodes

      In this command, /path/to/mykeystore.p12 is the PKCS12 formatted certificate and ui.keystore.pem is the converted x509 formatted certificate.

      Example:
      [root@localhost ~]# openssl pkcs12 -in /usr/local/zstack/zstack-ui/ui.keystore.p12 -out ui.keystore.pem -nodes
      Enter Import Password:
      MAC verified OK
    3. Edit the zstack.properties configuration file in /usr/local/zstack/apache-tomcat/webapps/zstack/WEB-INF/classes/zstack.properties, and set the certificate path to an absolute path (pointing to the certificate private key password file).
      consoleProxyCertFile = /usr/local/zstack/zstack-ui/ui.keystore.pem
  3. Run the following command to automatically generate a certificate based on the default configuration and log in to the UI using HTTPS with the default certificate. The default port is 5443.
    zstack-ctl config_ui --enable-ssl True
  4. Run the following command on the management node to enable the management node service and UI service.
    zstack-ctl start
  5. To access the ZStack Cloud management interface (https://your_domain_name:5443), use a Chrome or Firefox browser. Enter the default username and password (admin/password) to log in to the UI via HTTPS.
  6. Set the console proxy address.

    Log in to the UI interface, on the main menu of ZStack Cloud, choose Operational Management > Access Control > Console Proxy and set the console proxy as your_domain_name to make sure the console opens properly.

Log in to UI with Custom HTTPS Configuration

About this task

By default, the Cloud supports logging in to the UI using HTTPS with the custom certificate.

Procedure

  1. A custom certificate is required. You can generate a system self-signed certificate using related tools or purchase a certificate issued by a commercial CA.
    You can use Keytool (a Java data certificate management tool) to generate a self-signed certificate.
    mkdir certs
    
    keytool -genkey -alias tomcat  -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore ./certs/keystore.p12 -validity 365
    Example:
    [root@localhost ~]# mkdir certs
    [root@localhost ~]# keytool -genkey -alias tomcat  -storetype PKCS12 -keyalg RSA -keysize 2048 \
    -keystore ./certs/keystore.p12 -validity 365
    Enter keystore password:
    Re-enter new password:
    What is your first and last name?
      [Unknown]:  Jack Chen
    What is the name of your organizational unit?
      [Unknown]:  ZStack
    What is the name of your organization?
      [Unknown]:  DOC
    What is the name of your City or Locality?
      [Unknown]:  SH
    What is the name of your State or Province?
      [Unknown]:  SH
    What is the two-letter country code for this organizational unit?
      [Unknown]:  CN
    Is CN=Jack Chen, OU=Cloud, O=DOC, L=SH, ST=SH, C=CN correct?
      [No]:  Yes
    [root@localhost certs]# ls
    keystore.p12
  2. On the management node, run following command to stop the management node service and the UI service.
    zstack-ctl stop
  3. Ensure that the VNC console proxy supports HTTPS.
    1. The VNC console proxy supports x509 formatted certificates by default. You can convert the certificate format if needed.
      For example, you can convert a PKCS12 formatted certificate into x509 format.
      openssl pkcs12 -in /path/to/mykeystore.p12 -out ui.keystore.pem -nodes

      In this command, /path/to/mykeystore.p12 is the PKCS12 formatted certificate and ui.keystore.pem is the converted x509 formatted certificate.

      Example:
      [root@localhost ~]# openssl pkcs12 -in /root/certs/keystore.p12 -out ui.keystore.pem -nodes
      Enter Import Password:
      MAC verified OK
    2. Modify the zstack.properties configuration file. Set the certificate path to an absolute path (the absolute path points to the certificate private key password file).
      consoleProxyCertFile = /usr/local/zstack/zstack-ui/ui.keystore.pem
  4. Run following command to customize certificate alias, certificate path, certificate type, private key password, HTTPS login port, and other information. Then log in to the UI via HTTPS using the custom certificate.
    zstack-ctl config_ui --enable-ssl True \
    --ssl-keyalias=*** --ssl-keystore=*** --ssl-keystore-type=*** \
    --ssl-keystore-password=*** --server-port=*** --webhook-port=***
    //Record the custom parameter information in the zstack.ui.properties configuration file.
    //Including settings for: enabling HTTPS, certificate alias, certificate path, certificate type, private key password, HTTPS login port.
    
    zstack-ctl show_ui_config //View the custom parameter information
    
    zstack-ctl stop_ui
    zstack-ctl start_ui //Log in to the UI via HTTPS each time
    Example:
    [root@localhost ~]# zstack-ctl config_ui --enable-ssl True \
    --ssl-keyalias=tomcat --ssl-keystore=/root/certs/keystore.p12 --ssl-keystore-type=PKCS12 \
    --ssl-keystore-password=password --server-port=8888
    [root@localhost ~]# zstack-ctl show_ui_config
    db_url = jdbc:mysql://10.0.233.184:3306
    db_username = zstack_ui
    db_password = zstack.ui.password
    mn_host = 127.0.0.1
    mn_port = 8080
    webhook_host = 127.0.0.1
    webhook_port = 5000
    server_port = 8888
    log = /usr/local/zstack/apache-tomcat/logs
    enable_ssl = true
    ssl_keyalias = tomcat
    ssl_keystore = /usr/local/zstack/zstack-ui/ui.keystore.p12.cp
    ssl_keystore_type = PKCS12
    ssl_keystore_password = password
    [root@localhost ~]# zstack-ctl stop_ui
    successfully stopped the UI server
    [root@localhost ~]# zstack-ctl start_ui
    successfully started UI server on the local host, PID[32166], https://10.0.233.184:8888
  5. On the management node, run following command to start the management node service and the UI service.
    zstack-ctl start
  6. Enter the ZStack Cloud management interface (https://your_domain_name:your_server_port) using a Chrome or Firefox browser. Enter the default username and password (admin/password) to log in via custom HTTPS.
    Note:
    If you encounter issues with accessing VNC console using Firefox browser, follow these steps:
    1. Access https://your_domain_name:4900 using Firefox browser.
    2. Follow the prompts from the Firefox browser and add https://your_domain_name:4900 to the security exceptions.
    3. Open the VNC console using the Firefox browser.

    For more information, see Firefox.

  7. Set the console proxy address.

    Log in to the UI interface, on the main menu of ZStack Cloud, choose Operational Management > Access Control > Console Proxy and set the console proxy to your_domain_name to make sure the console opens properly.

Switch Back to HTTP for UI Login

Procedure

  1. Run the following command to restore the HTTPS related parameters in the zstack.ui.properties to the system default values.
    zstack-ctl config_ui --restore
  2. Run zstack-ctl stop_ui and zstack-ctl start_ui.
    Example:
    [root@localhost ~]# zstack-ctl config_ui --restore
    [root@localhost ~]# zstack-ctl show_ui_config
    db_url = jdbc:mysql://10.0.233.184:3306
    db_username = zstack_ui
    db_password = zstack.ui.password
    mn_host = 127.0.0.1
    mn_port = 8080
    webhook_host = 127.0.0.1
    webhook_port = 5000
    server_port = 5000
    log = /usr/local/zstack/apache-tomcat/logs
    enable_ssl = false
    ssl_keyalias = zstackui
    ssl_keystore = /usr/local/zstack/zstack-ui/ui.keystore.p12
    ssl_keystore_type = PKCS12
    ssl_keystore_password = password
    [root@localhost ~]# zstack-ctl stop_ui
    successfully stopped the UI server
    [root@localhost ~]# zstack-ctl start_ui
    successfully started UI server on the local host, PID[43261], http://10.0.233.184:5000
  3. Enter the ZStack Cloud management interface (https://your_domain_name:your_server_port) using a Chrome or Firefox browser. Enter the default username and password (admin/password). Then, you can switch back to HTTP for UI login.
  4. Set the console proxy address.

    Log in to the UI interface, on the main menu of ZStack Cloud, choose Operational Management > Access Control > Console Proxy and set the console proxy to your_domain_name to make sure the console opens properly.

What to do next

Now, you have learned how to log in to the UI interface via HTTPS.

Multiple Management Nodes Scenario

This section primarily focuses on scenarios involving multiple management nodes and you will learn:
  • How to log in to the UI with custom HTTPS configuration
  • How to switch back to HTTP for UI login

Log in to UI with Custom HTTPS Configuration

About this task

Under a dual management node scenario, you can log in to the UI using HTTPS with the custom certificate.

Procedure

  1. Prepare a multi-domain HTTPS certificate.
    • Prepare a multi-domain HTTPS certificate in advance, for example, *.test.com.
    • Bind each of the two management nodes and the VIP to a domain, for example, mna.test.com (management nodeA), mnb.test.com (management nodeB), and mn.test.com (VIP).
  2. Run the following command on both management nodes to stop the management service, UI service, and the zsha2 service.
    [root@localhost ~]# zsha2 stop-node
  3. Ensure the VNC console supports HTTPS.

    Both management nodes must ensure the VNC console supports HTTPS. For more information, see Step 3.

  4. Configure the parameters.

    Customize the certificate alias, certificate path, certificate type, private key password, HTTPS login port, and other information on both management nodes. Then, log in to the UI via HTTPS using the custom certificate. For more information, see Step 4.

  5. Run the following command on both management nodes to start the management node service, UI service, and the zsha2 service.
    [root@localhost ~]# zsha2 start-node
  6. Use a custom certificate to log in to the UI via HTTPS.
    Enter the ZStack Cloud management interface (https://your_domain_name:your_server_port) using a Chrome or Firefox browser. Enter the default username and password (admin/password) to log in via custom HTTPS.
    Note:
    If you encounter issues with accessing VNC console using Firefox browser, follow these steps:
    1. Access https://your_domain_name:4900 using Firefox browser.
    2. Follow the prompts from the Firefox browser and add https://your_domain_name:4900 to the security exceptions.
    3. Open the VNC console using the Firefox browser.

    For more information, see Firefox.

  7. Set the console proxy address.

    Log in to the UI interface, on the main menu of ZStack Cloud, choose Operational Management > Access Control > Console Proxy. Set the console proxy to your_domain_name, for example, mna.test.com (management nodeA) and mnb.test.com (management nodeB) to make sure the console opens properly.

Switch Back to HTTP for UI Login

About this task

Under a dual management node scenario, you can restore the default HTTP method to log in to the UI.

Procedure

  1. Run the following command on both management nodes to stop the management service, UI service, and the zsha2 service.
    [root@localhost ~]# zsha2 stop-node
  2. Disable the HTTPS feature.
    Run the following command on each of the two management nodes to restore the HTTPS related parameters in the zstack.ui.properties to their system default values.
    [root@localhost ~]# zstack-ctl config_ui --restore
  3. Reconfigure webhook-host.
    Run the following command on each of the two management nodes to configure the webhook-host address to the VIP address of the dual management nodes.
    [root@localhost ~]# zstack-ctl config_ui --webhook-host VIP
  4. Run the following command on both management nodes to start the management node service, UI service, and the zsha2 service.
    [root@localhost ~]# zsha2 start-node
  5. Log in to the UI interface via HTTP

    Enter the ZStack Cloud management interface (http://your_machine_ip:5000) using a Chrome or Firefox browser. Enter the default username and password (admin/password). Then, you can switch back to HTTP for UI login.

  6. Set the console proxy address.

    Log in to the UI interface, on the main menu of ZStack Cloud, choose Operational Management > Access Control > Console Proxy and set the console proxy to your_machine_ip to make sure the console opens properly.

What to do next

Now, you have learned how to log in to the UI interface via HTTPS under a dual management nodes scenario.

UI Login Through HTTPS Tutorial | 4.8.38 | ZStack Cloud · ZCF | ZStack Resource Center