Tutorial Tutorial Tutorial Application Services Application Services Application Services ~32 phút ~32 min ~32 នាទី Đồng bộ 2026-06-10 Synced 2026-06-10 ធ្វើសមកាល 2026-06-10

Phần mềm v2 SoftHSMv2 ហ្វេសប៊ុក

Hướng dẫn chi tiết đồng bộ từ docs Cloudflare — mỗi section có backlink tới đúng vị trí trên trang gốc. Detailed guide synced from Cloudflare docs — each section links to the matching anchor on the official page. មគ្គុទ្ទេសក៍លម្អិតធ្វើសមកាលពី docs Cloudflare — ផ្នែកនីមួយៗមានតំណទៅទីតាំងត្រូវគ្នានៅទំព័រផ្លូវការ។

← Danh mục ← Catalog ← បញ្ជី

Giải thích nhanh Quick context បរិបទរហ័ស

Thuộc nhóm Application Services — tập trung bảo vệ, tăng tốc và vận hành ứng dụng/web phía trước origin. Tutorial «SoftHSMv2» giúp bạn làm quen luồng triển khai thật — phù hợp đọc trước khi mở tài liệu gốc tiếng Anh. Docs gốc chia khoảng 4 bước chính; bản tóm tắt dưới đây giúp bạn nắm khung trước khi làm theo từng lệnh.

Learn how to use Keyless SSL with SoftHSMv2.

តើធ្វើដូចម្តេចដើម្បីប្រើ Keyless SSL ជាមួយ SoftHSMv2 ។

Lưu ý Note ចំណាំ

Lưu ý trước khi làm Notes before you start ចំណាំមុនពេលចាប់ផ្តើម

  • Đây là bản tóm tắt trên Orange Cloud Learning Hub — không thay thế tài liệu chính thức.
  • Luôn mở liên kết «Tài liệu gốc» bên dưới khi cần lệnh CLI, snippet code và ảnh minh họa đầy đủ.
  • Docs Cloudflare cập nhật thường xuyên — đối chiếu ngày «Rà soát lần cuối» trên trang gốc khi triển khai production.
  • This is a summary on Orange Cloud Learning Hub — it does not replace the official documentation.
  • Open the Official docs link below for CLI commands, code snippets, and full screenshots.
  • Cloudflare docs change frequently — verify the Last reviewed date on the official page before production use.
  • នេះគឺជាការបញ្ជាក់អំពី Orange Cloud Learning Hub — វាគឺជាការផ្លាស់ប្តូរនៃឯកសារផ្លូវការ។
  • ចុចតំណភ្ជាប់ Docs Official នៅខាងក្រោមសម្រាប់ការបញ្ជា CLI, សៀវភៅកូដនិងរូបថតពេញលេញ។
  • Cloudflare បានផ្លាស់ប្តូរជាធម្មតានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅពេលវេលានៅ។

Overview Overview Overview

Phần «Tổng quan» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Overview" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «Overview» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
quan trọng
Important
សំខាន់
SoftHSMv2 không nên được coi là an toàn hơn so với việc lưu trữ khóa riêng trực tiếp trên đĩa. Không có nỗ lực nào được thực hiện dưới đây để bảo vệ cài đặt này; nó chỉ được cung cấp cho mục đích chứng minh.
SoftHSMv2 should not be considered any more secure than storing private keys directly on disk. No attempt is made below to secure this installation; it is provided simply for demonstration purposes.
SoftHSMv2 មិនគួរតែត្រូវបានគេស្គាល់ថាជាការសុវត្ថិភាពជាងការរក្សាទុកគោលបំណងឯកជនដោយផ្ទាល់នៅលើខ្សែភាពយន្ត។ គ្មានការធ្វើការនៅក្រោមនេះដើម្បីសុវត្ថិភាពការដំឡើងនេះ; វាគឺជាការផ្តល់ជូនតែសម្រាប់គោលបំណងការបង្ហាញ។
---
---
---

1.Điều Cài đặt và cấu hình SoftHSMv2 1. Install and configure SoftHSMv2 1 ។ ការដំឡើងនិងការកំណត់ SoftHSMv2

Phần «Cài đặt và configure SoftHSMv2» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "1. Install and configure SoftHSMv2" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «1 ។ ការដំឡើងនិងការកំណត់ SoftHSMv2» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Đầu tiên, chúng tôi cài đặt SoftHSMv2 và cấu hình nó để lưu trữ token ở vị trí mặc định /var/lib/softhsm/tokens. Chúng tôi cũng cần cấp quyền cho nhóm softhsm cho thư mục này vì đây là cách người dùng keyless sẽ access thư mục này.
First, we install SoftHSMv2 and configure it to store tokens in the default location /var/lib/softhsm/tokens. We also need to give the softhsm group permission to this directory as this is how the keyless user will access this directory.
ជាលើកដំបូងយើងដំឡើង SoftHSMv2 និងកំណត់វាដើម្បីរក្សាទុក tokens នៅលើទីតាំងទូទាត់ /var/lib/softhsm/tokens ។ យើងក៏ត្រូវការផ្តល់អនុញ្ញាតដល់ក្រុម softhsm ទៅមេឡិចត្រូនិកនេះដូច្នេះដូច្នេះអ្នកប្រើ keyless នឹង access មេឡិចត្រូនិកនេះ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
sudo apt-get install -y softhsm2 opensc


#...


cat <<EOF | sudo tee /etc/softhsm/softhsm2.conf

directories.tokendir = /var/lib/softhsm/tokens

objectstore.backend = file

log.level = DEBUG

slots.removable = false

EOF


sudo mkdir /var/lib/softhsm/tokens

sudo chown root:softhsm $_

sudo chmod 0770 /var/lib/softhsm/tokens

sudo usermod -G softhsm keyless

sudo usermod -G softhsm $(whoami)


echo 'export SOFTHSM2_CONF=/etc/softhsm/softhsm2.conf' | tee -a ~/.profile

source ~/.profile
---
---
---

2.Đối với Tạo token và private keys, và tạo CSR 2. Create a token and private keys, and generate CSRs 2 ។ បានបង្កើត token និង private keys និងបង្កើត CSRs

Phần «Tạo token và private keys, và generate CSRs» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "2. Create a token and private keys, and generate CSRs" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «2 ។ បានបង្កើត token និង private keys និងបង្កើត CSRs» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Tiếp theo, chúng tôi tạo ra một token trong khe 0 được gọi là test-token và bảo mật nó với mã PIN 1234. Trong khe này, chúng tôi sẽ lưu trữ các phím RSA cho chứng chỉ SSL của chúng tôi cho keyless-softhsm.example.com.
Next, we create a token in slot 0 called test-token and secure it with a PIN of 1234. In this slot we’ll store the RSA keys for our SSL certificates for keyless-softhsm.example.com.
បន្ទាប់មកយើងបានបង្កើត token នៅលើ slot 0 ដែលត្រូវបានគេហៅថា test-token និងការពារវាជាមួយនឹង PIN នៃ 1234 ។ ក្នុងកំណត់នេះយើងនឹងរក្សាទុកគោលដៅ RSA សម្រាប់វិញ្ញាបនប័ត្រ SSL របស់យើងសម្រាប់ keyless-softhsm.example.com ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
sudo -u keyless softhsm2-util --init-token --slot 0 --label test-token --pin 1234 --so-pin 4321
text
The token has been initialized.
Sử dụng cfssl, chúng tôi tạo ra private keys and Certificate Signing Requests (CSRs) ↗, sau này sẽ được gửi đến một Cơ quan Chứng chỉ (CA) để ký.
Using cfssl, we generate the private keys and Certificate Signing Requests (CSRs) ↗, the latter of which will be sent to a Certificate Authority (CA) for signing.
ការប្រើប្រាស់ cfssl យើងបានបង្កើត private keys and Certificate Signing Requests (CSRs) ↗ ដែលចុងក្រោយនេះនឹងត្រូវបានផ្ញើទៅអ្នកគ្រប់គ្រងវិញ្ញាបនប័ត្រ (CA) សម្រាប់ការសន្សំ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
cat <<EOF | tee csr.json

{

    "hosts": [

        "keyless-softhsm.example.com"

    ],

    "CN": "keyless-softhsm.example.com",

    "key": {

        "algo": "rsa",

        "size": 2048

    },

    "names": [{

        "C": "US",

        "L": "San Francisco",

        "O": "TLS Fun",

        "OU": "Technical Operations",

        "ST": "California"

    }]

}

EOF


cfssl genkey csr.json | cfssljson -bare certificate
text
2018/08/12 00:52:22 [INFO] generate received request

2018/08/12 00:52:22 [INFO] received CSR

2018/08/12 00:52:22 [INFO] generating key: rsa-2048

2018/08/12 00:52:22 [INFO] encoded CSR
---
---
---

3 Cái Chuyển đổi và nhập khẩu khóa 3. Convert and import the key 3 ។ ការផ្លាស់ប្តូរនិងនាំចូលគោលបំណង

Phần «Chuyển đổi và import key» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "3. Convert and import the key" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «3 ។ ការផ្លាស់ប្តូរនិងនាំចូលគោលបំណង» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Bây giờ chìa khóa đã được tạo ra, đã đến lúc tải nó vào khe mà chúng tôi đã tạo ra. Trước khi làm như vậy, chúng ta cần chuyển đổi từ PKCS#1 sang PKCS#8 định dạng. Trong quá trình nhập khẩu, chúng tôi chỉ định mã token và mã PIN từ việc bắt đầu mã token và cung cấp ID và label duy nhất cho khóa.
Now that the key has been generated, it’s time to load it into the slot we created. Before doing so, we need to convert from PKCS#1 to PKCS#8 format. During import, we specify the token and PIN from token initialization and provide a unique hexadecimal ID and label to the key.
Now that the key has been generated, it’s time to load it into the slot we created។ មុនពេលធ្វើដូច្នេះយើងត្រូវការផ្លាស់ប្តូរពី PKCS#1 ទៅ PKCS#8 គំរូ។ ក្នុងពេលការនាំចូលយើងបញ្ជាក់ token និង PIN ពីការចាប់ផ្តើម token និងផ្តល់ ID hexadecimal និង label មួយតែមួយដើម្បីគោលដៅ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in certificate-key.pem -out certificate-key.p8

sudo chown keyless certificate-key.p8


sudo -u keyless softhsm2-util --pin 1234 --import ./certificate-key.p8 --token test-token --id a000 --label rsa-privkey
text
Found slot 915669571 with matching token label.

The key pair has been imported.
Sau khi nhập chúng tôi yêu cầu pkcs11-tool để xác nhận các đối tượng đã được lưu trữ thành công trong token.
After importing we ask pkcs11-tool to confirm the objects have been successfully stored in the token.
បន្ទាប់ពីការនាំចូលយើងគួរ pkcs11-tool ដើម្បីបញ្ជាក់ថាអតិថិជនទាំងនេះត្រូវបានរក្សាទុកយ៉ាងជោគជ័យនៅក្នុង token ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
sudo -u keyless pkcs11-tool --module /usr/lib/softhsm/libsofthsm2.so -l -p 1234 --token test-token --list-objects
text
Public Key Object; RSA 2048 bits

  label:      rsa-privkey

  ID:         a000

  Usage:      verify

Private Key Object; RSA

  label:      rsa-privkey

  ID:         a000

  Usage:      sign
---
---
---

Bốn Thay đổi tập tin cấu hình không gokeyless của bạn và khởi động lại dịch vụ 4. Modify your gokeyless config file and restart the service 4 ។ ការផ្លាស់ប្តូរឯកសារ Config Gokeyless របស់អ្នកនិងចាប់ផ្តើមសេវាកម្មថ្មី

Phần «Modify your gokeyless config file và restart service» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "4. Modify your gokeyless config file and restart the service" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «4 ។ ការផ្លាស់ប្តូរឯកសារ Config Gokeyless របស់អ្នកនិងចាប់ផ្តើមសេវាកម្មថ្មី» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Với các phím tại chỗ, đã đến lúc xây dựng tệp cấu hình mà máy chủ phím sẽ đọc khi khởi động. id đề cập đến ID thập phân mà bạn đã cung cấp cho tuyên bố nhập softhsm2-util; chúng tôi đã sử dụng a000 để nó được mã hóa là %a0%00. module-path sẽ thay đổi một chút dựa trên bản phân phối Linux bạn đang sử dụng. Trên Debian, nó nên là /usr/lib/softhsm/libsofthsm2.so.
With the keys in place, it’s time to build the configuration file that the key server will read on startup. The id refers to the hexadecimal ID you provided to the softhsm2-util import statement; we used a000 so it is encoded as %a0%00. The module-path will vary slightly based on the Linux distribution you are using. On Debian it should be /usr/lib/softhsm/libsofthsm2.so.
ជាមួយនឹងគោលបំណងដែលមាននៅទីនេះវាត្រូវបានកំណត់ពេលវេលាដើម្បីបង្កើតឯកសារកំណត់ដែលអ្នកផ្គត់ផ្គង់គោលបំណងនឹងអាននៅពេលចាប់ផ្តើម។ id បានផ្លាស់ប្តូរទៅអ៊ីនធឺណិត hexadecimal ដែលអ្នកបានផ្តល់នូវការបញ្ចូល softhsm2-util ។ យើងបានប្រើ a000 ដូច្នេះវាត្រូវបានកូដជា %a0%00 ។ module-path នឹងប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រែប្រ នៅលើ Debian វាគឺជា /usr/lib/softhsm/libsofthsm2.so ។
Mở /etc/keyless/gokeyless.yaml và ngay sau đó
Open up /etc/keyless/gokeyless.yaml and immediately after
ចុច /etc/keyless/gokeyless.yaml ហើយបន្ទាប់ពីនេះ
YAML
YAML
YAML
text
private_key_stores:

  - dir: /etc/keyless/keys
add
add
add
YAML
YAML
YAML
text
- uri: pkcs11:token=test-token;id=%a0%00?module-path=/usr/lib/softhsm/libsofthsm2.so&pin-value=1234&max-sessions=1
Lưu tệp config, khởi động lại gokeyless và xác minh nó đã bắt đầu thành công.
Save the config file, restart gokeyless, and verify it started successfully.
ទាញយកឯកសារ config, reboot gokeyless, និងត្រួតពិនិត្យវាបានចាប់ផ្តើមយ៉ាងជោគជ័យ។
Cửa sổ Terminal
Terminal window
បង្វិល Terminal
text
sudo systemctl restart gokeyless.service

sudo systemctl status gokeyless.service -l
json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/ssl/","name":"SSL/TLS"}},{"@type":"ListItem","position":3,"item":{"@id":"/ssl/keyless-ssl/","name":"Keyless SSL"}},{"@type":"ListItem","position":4,"item":{"@id":"/ssl/keyless-ssl/hardware-security-modules/","name":"Hardware security modules"}},{"@type":"ListItem","position":5,"item":{"@id":"/ssl/keyless-ssl/hardware-security-modules/softhsmv2/","name":"SoftHSMv2"}}]}

Xem bản đầy đủ trên developers.cloudflare.com (ảnh, tab cấu hình). View the full guide on developers.cloudflare.com (images, config tabs). មើលមគ្គុទ្ទេសក៍ពេញលើ developers.cloudflare.com (រូបភាព, tab កំណត់)។

Tài liệu gốc ↗ Official docs ↗ ឯកសារផ្លូវការ ↗