Cài đặt mqtts với moquette

Để cài đặt mqtts hỗ trợ authencation ssl

B1: Tạo file serverkeystore.jks

Chạy dòng lệnh sau. Sao đó trả lời các câu hỏi sau:

 

C:\Users\NXCOMM>keytool -keystore serverkeystore.jks -alias testserver -genkey -keyalg RSA

Enter keystore password:

Re-enter new password:

What is your first and last name?

  [Unknown]:  cu tran

What is the name of your organizational unit?

  [Unknown]:  plk

What is the name of your organization?

  [Unknown]:  plk

What is the name of your City or Locality?

  [Unknown]:  ho chi minh

What is the name of your State or Province?

  [Unknown]:  ho chi minh

What is the two-letter country code for this unit?

  [Unknown]:  VN

Is CN=cu tran, OU=plk, O=plk, L=ho chi minh, ST=ho chi minh, C=VN correct?

  [no]:  y

 

Enter key password for <testserver>

        (RETURN if same as keystore password):

Re-enter new password:

 

C:\Users\NXCOMM>

 

Note: nhớ password để config trong file config/moquette.conf

Xuất file serverkeystore.jks bằng các lệnh:

 

C:\Users\NXCOMM>keytool -export -alias testserver -keystore serverkeystore.jks -file testserver.crt

Enter keystore password:

Certificate stored in file <testserver.crt>

 

B2. Vào chỉnh sửa file config/moquette.conf

Thêm code config ssl cho broker:

 

ssl_port 8883

jks_path config/serverkeystore.jks

key_store_password 123456

key_manager_password 123456

 

Nhớ copy file serverkeystore.jks vào thư muc config trước khi restart lại broker.

B3. Restart lại broker vào dùng mqtt client connect vào địa chỉ:

ssl://localhost:8883

username/password: testuser/ passwd

Bạn có thể thêm user bằng cách thêm vào file config/password_file.conf

Chú ý password được mã hóa với sha256.