

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# PKCS\#11 供應商
<a name="pkcs11-provider-component"></a>

PKCS\#11 提供者元件 (`aws.greengrass.crypto.Pkcs11Provider`) 可讓您將 AWS IoT Greengrass Core 軟體設定為透過 [PKCS\#11 界面](https://en.wikipedia.org/wiki/PKCS_11)使用硬體安全模組 (HSM)。此元件可讓您安全地存放憑證和私有金鑰檔案，使其不會在軟體中公開或複製。如需詳細資訊，請參閱[硬體安全整合](hardware-security.md)。

**注意**  
僅 [Greengrass 核](greengrass-nucleus-component.md)需要此元件。[Greengrass nucleus lite](greengrass-nucleus-lite-component.md) v2.5.0 和更新版本包含內建 PKCS\#11 支援，不需要此元件。如需詳細資訊，請參閱 nucleus lite GitHub AWS IoT Greengrass 儲存庫中的 [PKCS\#11 支援](https://github.com/aws-greengrass/aws-greengrass-lite/blob/main/docs/PKCS11_SUPPORT.md)。

若要佈建將其憑證和私有金鑰存放在 HSM 中的 Greengrass 核心裝置，您必須在安裝 AWS IoT Greengrass Core 軟體時將此元件指定為佈建外掛程式。如需詳細資訊，請參閱[使用手動資源佈建安裝 AWS IoT Greengrass 核心軟體](manual-installation.md)。

AWS IoT Greengrass 提供此元件做為 JAR 檔案，您可以在安裝期間下載此檔案以指定 做為佈建外掛程式。您可以將元件 JAR 檔案的最新版本下載為下列 URL：https：//[https://d2s8p88vqu9w66.cloudfront.net/releases/Pkcs11Provider/aws.greengrass.crypto.Pkcs11Provider-latest.jar](https://d2s8p88vqu9w66.cloudfront.net/releases/Pkcs11Provider/aws.greengrass.crypto.Pkcs11Provider-latest.jar)。

**Topics**
+ [版本](#pkcs11-provider-component-versions)
+ [Type](#pkcs11-provider-component-type)
+ [作業系統](#pkcs11-provider-component-os-support)
+ [要求](#pkcs11-provider-component-requirements)
+ [相依性](#pkcs11-provider-component-dependencies)
+ [Configuration](#pkcs11-provider-component-configuration)
+ [本機日誌檔案](#pkcs11-provider-component-log-file)
+ [變更記錄](#pkcs11-provider-component-changelog)

## 版本
<a name="pkcs11-provider-component-versions"></a>

此元件具有下列版本：
+ 2.0.x

## Type
<a name="pkcs11-provider-component-type"></a>

<a name="public-component-type-plugin-para1"></a>此元件是外掛程式元件 (`aws.greengrass.plugin`)。[Greengrass 核心](greengrass-nucleus-component.md)會在與核心相同的 Java 虛擬機器 (JVM) 中執行此元件。當您在核心裝置上變更此元件的版本時，核心會重新啟動。

<a name="public-component-type-plugin-para2"></a>此元件使用與 Greengrass 核相同的日誌檔案。如需詳細資訊，請參閱[監控 AWS IoT Greengrass 日誌](monitor-logs.md)。

<a name="public-component-type-more-information"></a>如需詳細資訊，請參閱[元件類型](develop-greengrass-components.md#component-types)。

## 作業系統
<a name="pkcs11-provider-component-os-support"></a>

此元件只能在 Linux 核心裝置上安裝。

## 要求
<a name="pkcs11-provider-component-requirements"></a>

此元件有下列需求：
+ <a name="hardware-security-module-requirements-key"></a>支援 [PKCS\#1 v1.5 ](https://tools.ietf.org/html/rfc2313)簽章結構描述和具有 RSA-2048 金鑰大小 （或更大） 或 ECC 金鑰的 RSA 金鑰的硬體安全模組。
**注意**  <a name="hardware-security-module-requirements-key-notes"></a>
若要搭配 ECC 金鑰使用硬體安全模組，您必須使用 [Greengrass nucleus](greengrass-nucleus-component.md) v2.5.6 或更新版本。  
若要使用硬體安全模組和[秘密管理員](secret-manager-component.md)，您必須搭配 RSA 金鑰使用硬體安全模組。
+ <a name="hardware-security-module-requirements-pkcs11-provider-library"></a> AWS IoT Greengrass 核心軟體可在執行時間 （使用 libdl) 載入的 PKCS\#11 提供者程式庫，以叫用 PKCS\#11 函數。PKCS\#11 提供者程式庫必須實作下列 PKCS\#11 API 操作：
  + `C_Initialize`
  + `C_Finalize`
  + `C_GetSlotList`
  + `C_GetSlotInfo`
  + `C_GetTokenInfo`
  + `C_OpenSession`
  + `C_GetSessionInfo`
  + `C_CloseSession`
  + `C_Login`
  + `C_Logout`
  + `C_GetAttributeValue`
  + `C_FindObjectsInit`
  + `C_FindObjects`
  + `C_FindObjectsFinal`
  + `C_DecryptInit`
  + `C_Decrypt`
  + `C_DecryptUpdate`
  + `C_DecryptFinal`
  + `C_SignInit`
  + `C_Sign`
  + `C_SignUpdate`
  + `C_SignFinal`
  + `C_GetMechanismList`
  + `C_GetMechanismInfo`
  + `C_GetInfo`
  + `C_GetFunctionList`
+ <a name="hardware-security-module-requirements-slot-label"></a>硬體模組必須可透過插槽標籤根據 PKCS\#11 規格中的定義來解析。
+ <a name="hardware-security-module-requirements-private-key-and-certificate"></a>您必須將私有金鑰和憑證存放在相同插槽的 HSM 中，如果 HSM 支援物件 ID，則必須使用相同的物件標籤和物件 IDs。
+ <a name="hardware-security-module-requirements-object-label"></a>憑證和私有金鑰必須透過物件標籤解析。
+ <a name="hardware-security-module-requirements-private-key-permissions"></a>私有金鑰必須具有下列許可：
  + `sign`
  + `decrypt`
+ <a name="hardware-security-module-requirements-secret-manager-permissions"></a>（選用） 若要使用[秘密管理員元件](secret-manager-component.md)，您必須使用 2.1.0 版或更新版本，且私有金鑰必須具有下列許可：
  + `unwrap`
  + `wrap`
+ <a name="hardware-security-module-requirements-environment-variable"></a>（選用） 如果您使用 TPM2 程式庫並執行 Greengrass 核心做為服務，則必須提供具有 PKCS\#11 存放區位置的環境變數。下列範例是具有必要環境變數的系統化服務檔案：

  ```
  [Unit]
  Description=Greengrass Core
  After=network.target
  
  [Service]
  Type=simple
  PIDFile=/var/run/greengrass.pid
  Environment=TPM2_PKCS11_STORE={{/path/to/store/directory}}
  RemainAfterExit=no
  Restart=on-failure
  RestartSec=10
  ExecStart=/bin/sh /greengrass/v2/alts/current/distro/bin/loader
  
  [Install]
  WantedBy=multi-user.target
  ```

## 相依性
<a name="pkcs11-provider-component-dependencies"></a>

當您部署元件時， AWS IoT Greengrass 也會部署其相依性的相容版本。這表示您必須符合元件及其所有相依性的要求，才能成功部署元件。本節列出此元件[發行版本的](#pkcs11-provider-component-changelog)相依性，以及為每個相依性定義元件版本的語意版本限制。您也可以在 [AWS IoT Greengrass 主控台](https://console.aws.amazon.com//greengrass)中檢視每個版本元件的相依性。在元件詳細資訊頁面上，尋找**相依性**清單。

------
#### [ 2.0.11 ]

下表列出此元件 2.0.11 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.17.0 | 軟式 | 

------
#### [ 2.0.10 ]

下表列出此元件 2.0.10 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.16.0  | 軟式 | 

------
#### [ 2.0.9 ]

下表列出此元件 2.0.9 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.15.0  | 軟式 | 

------
#### [ 2.0.8 ]

下表列出此元件 2.0.8 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.14.0  | 軟式 | 

------
#### [ 2.0.7 ]

下表列出此元件 2.0.7 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.13.0  | 軟式 | 

------
#### [ 2.0.6 ]

下表列出此元件 2.0.6 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.12.0  | 軟式 | 

------
#### [ 2.0.5 ]

下表列出此元件 2.0.5 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.11.0  | 軟式 | 

------
#### [ 2.0.4 ]

下表列出此元件 2.0.4 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.10.0  | 軟式 | 

------
#### [ 2.0.3 ]

下表列出此元件 2.0.3 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.9.0  | 軟式 | 

------
#### [ 2.0.2 ]

下表列出此元件 2.0.2 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) | >=2.5.3 <2.8.0  | 軟式 | 

------
#### [ 2.0.1 ]

下表列出此元件 2.0.1 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) |  >=2.5.3 <2.7.0  | 軟式 | 

------
#### [ 2.0.0 ]

下表列出此元件 2.0.0 版的相依性。


| 相依性 | 相容版本 | 相依性類型 | 
| --- | --- | --- | 
| [Greengrass 核](greengrass-nucleus-component.md) |  >=2.5.3 <2.6.0  | 軟式 | 

------

如需元件相依性的詳細資訊，請參閱[元件配方參考](component-recipe-reference.md#recipe-reference-component-dependencies)。

## Configuration
<a name="pkcs11-provider-component-configuration"></a>

此元件提供下列組態參數，您可以在部署元件時自訂這些參數。<a name="pkcs11-provider-component-configuration-parameters"></a>

`name`  
PKCS\#11 組態的名稱。

`library`  
 AWS IoT Greengrass 核心軟體可使用 libdl 載入之 PKCS\#11 實作程式庫的絕對檔案路徑。

`slot`  
包含私有金鑰和裝置憑證的插槽 ID。此值與槽索引或槽標籤不同。

`userPin`  
用來存取插槽的使用者 PIN 碼。

**Example 範例：組態合併更新**  

```
{
  "name": "softhsm_pkcs11",
  "library": "/usr/lib/softhsm/libsofthsm2.so",
  "slot": 1,
  "userPin": "1234"
}
```

## 本機日誌檔案
<a name="pkcs11-provider-component-log-file"></a>

此元件使用與 [Greengrass 核](greengrass-nucleus-component.md)元件相同的日誌檔案。

------
#### [ Linux ]

```
{{/greengrass/v2}}/logs/greengrass.log
```

------
#### [ Windows ]

```
{{C:\greengrass\v2}}\logs\greengrass.log
```

------

**檢視此元件的日誌**
+ 在核心裝置上執行下列命令，以即時檢視此元件的日誌檔案。將 `{{/greengrass/v2}}`或 {{C：\\greengrass\\v2}} 取代為 AWS IoT Greengrass 根資料夾的路徑。

------
#### [ Linux ]

  ```
  sudo tail -f {{/greengrass/v2}}/logs/greengrass.log
  ```

------
#### [ Windows (PowerShell) ]

  ```
  Get-Content {{C:\greengrass\v2}}\logs\greengrass.log -Tail 10 -Wait
  ```

------

## 變更記錄
<a name="pkcs11-provider-component-changelog"></a>

下表說明每個版本元件的變更。


|  **版本**  |  **變更**  | 
| --- | --- | 
| 2.0.12 | 更新 Greengrass nucleus 2.17.0 版的元件版本。 | 
| 2.0.11 | 針對 Greengrass nucleus 2.16.0 版更新版本。 | 
| 2.0.10 | 針對 Greengrass nucleus 2.15.0 版更新版本。 | 
| 2.0.9 | 針對 Greengrass nucleus 2.14.0 版更新版本。 | 
| 2.0.8 | 針對 Greengrass nucleus 2.13.0 版更新版本。 | 
| 2.0.7 | 針對 Greengrass nucleus 2.12.0 版更新版本。 | 
| 2.0.6 | 針對 Greengrass nucleus 2.11.0 版更新版本。 | 
| 2.0.5 | 針對 Greengrass nucleus 2.10.0 版更新版本。 | 
| 2.0.4 | 針對 Greengrass nucleus 2.9.0 版更新版本。 | 
| 2.0.3 | 針對 Greengrass nucleus 2.8.0 版更新版本。 | 
| 2.0.2 | 針對 Greengrass nucleus 2.7.0 版更新版本。 | 
| 2.0.1 | 針對 Greengrass nucleus 2.6.0 版更新版本。 | 
| 2.0.0 | 初始版本。 | 