Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Generating and Replacing a Certificate

Updated on 2024-04-07 GMT+08:00

When connecting a Kafka client to a Kafka instance that has SASL enabled, use either the certificate provided by DMS for Kafka or your own certificate. This section describes how to generate your own certificate and use it to replace the one provided by DMS for Kafka.

To generate and replace certificates, contact background support personnel to enable the function for you. This function is available on a whitelist basis in all regions.

NOTE:

Replacing the certificate will restart the instance. Exercise caution.

Prerequisites

  • A Linux server is available.
  • Kafka SASL_SSL has been enabled for the instance.

Step 1: Generating a Certificate

  1. Log in to the Linux server and run the following command to generate a keystore for the server.keystore.jks certificate:

    keytool -genkey -keystore server.keystore.jks -alias localhost -validity 3650 -keyalg RSA

    Enter a keystore password as prompted. The password must meet the following requirements:

    • Contains 8 to 32 characters.
    • Contains at least three of the following character types: letters, digits, spaces, and special characters `-!@#$ %^&*()-_=+\|[{}]:'",<.>/? and does not start with a hyphen (-).
    • Cannot be a weak password. To check whether a password is weak, enter it in 6.

    Enter the information about the certificate owner as prompted, such as the name, company, and city.

  2. Run the following command to generate a CA:

    openssl req -new -x509 -keyout ca-key -out ca-cert -days 3650

    Enter a PEM password as prompted.

    Enter the information about the certificate owner as prompted.

  3. The certificate validity can be checked only after a truststore certificate is created. Run the following command to create a server truststore certificate with the generated CA:

    keytool -keystore server.truststore.jks -alias CARoot -import -file ca-cert

    Enter the server truststore password as prompted. The password must meet the following requirements:

    • Contains 8 to 32 characters.
    • Contains at least three of the following character types: letters, digits, spaces, and special characters `-!@#$ %^&*()-_=+\|[{}]:'",<.>/? and does not start with a hyphen (-).
    • Cannot be a weak password. To check whether a password is weak, enter it in 6.
    Enter y when the following information is displayed:
    Trust this certificate?

  4. Run the following command to create a client truststore certificate with the CA:

    keytool -keystore client.truststore.jks -alias CARoot -import -file ca-cert

    Enter the client truststore password as prompted. This password is the value of ssl.truststore.password in the configuration file used by the client to connect to the Kafka instance.

    Enter y when the following information is displayed:
    Trust this certificate?

  5. Sign the server certificate.

    1. Export the server certificate server.cert-file.
      keytool -keystore server.keystore.jks -alias localhost -certreq -file server.cert-file

      Enter the keystore password set in 1 as prompted.

    2. Sign the server certificate with the CA.
      openssl x509 -req -CA ca-cert -CAkey ca-key -in server.cert-file -out server.cert-signed -days 3650 -CAcreateserial

      Enter the PEM password set in 2 as prompted.

    3. Import the CA certificate to the server keystore.
      keytool -keystore server.keystore.jks -alias CARoot -import -file ca-cert

      Enter the keystore password set in 1 as prompted.

      Enter y when the following information is displayed:
      Trust this certificate?
    4. Import the signed server certificate to the server keystore.
      keytool -keystore server.keystore.jks -alias localhost -import -file server.cert-signed

      Enter the keystore password set in 1 as prompted.

  6. Export the server.keystore.jks and server.truststore.jks certificates to the local PC.

    Figure 1 Certificate directory

Step 2: Replacing a Certificate

  1. Log in to the management console.
  2. Click in the upper left corner to select a region.

    NOTE:

    Select the same region as your application service.

  3. Click and choose Application > Distributed Message Service for Kafka to open the console of DMS for Kafka.
  4. Click the desired instance to view its details.
  5. In the Connection area, click Re-upload next to SSL Certificate.

    Figure 2 Connection information

  6. Set the parameters for replacing the SSL certificate by referring to Table 1.

    Figure 3 Replacing the SSL certificate
    Table 1 Parameters for replacing the SSL certificate

    Parameter

    Description

    Key Password

    Enter the keystore password set in 1.

    Keystore Password

    Enter the keystore password set in 1.

    Keystore File

    Import the server.keystore.jks certificate.

    Truststore Password

    Enter the server truststore password set in 3.

    Truststore File

    Import the server.truststore.jks certificate.

  7. Click OK.
  8. Click OK.

    On the Background Tasks page, if the certificate replacement task is Successful, the certificate is successfully replaced.
    NOTE:

    After the original certificate is successfully replaced, you will download the certificate provided by DMS for Kafka rather than your own certificate by clicking Download on the Basic Information tab page.

Step 3: Modifying Client Configuration Files

After a certificate is replaced, modify the ssl.truststore.location and ssl.truststore.password parameters in the consumer.properties and producer.properties files on the client, respectively.

security.protocol=SASL_SSL
ssl.truststore.location=/opt/kafka_2.12-2.7.2/config/client.truststore.jks
ssl.truststore.password=dms@kafka
ssl.endpoint.identification.algorithm=
  • ssl.truststore.location: path for storing the client.truststore.jks certificate.
  • ssl.truststore.password: truststore password of the client certificate
  • ssl.endpoint.identification.algorithm: whether to verify the certificate domain name. This parameter must be left blank, which indicates disabling domain name verification.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback