

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

# 設定 OPC UA 伺服器以信任 AWS IoT SiteWise Edge 閘道
<a name="enable-source-trust"></a>

如果您在設定 OPC UA 來源時選擇 **None** `messageSecurityMode`以外的其他 ，則必須啟用來源伺服器來信任 AWS IoT SiteWise Edge 閘道。SiteWise Edge 閘道會產生來源伺服器可能需要的憑證。程序會根據您的來源伺服器而有所不同。如需詳細資訊，請參閱您伺服器的文件。

下列程序概述基本步驟。

**讓 OPC UA 伺服器信任 SiteWise Edge 閘道**

1. 開啟用於設定 OPC UA 伺服器的界面。

1. 輸入 OPC UA 伺服器管理員的使用者名稱和密碼。

1. 在界面中尋找**信任的用戶端**，然後選擇**AWS IoT SiteWise 閘道用戶端**。

1. 選擇 **Trust (信任)**。

## 匯出 OPC UA 用戶端憑證
<a name="export-opc-ua-client-certificate"></a>

有些 OPC UA 伺服器需要存取 OPC UA 用戶端憑證檔案，才能信任 SiteWise Edge 閘道。如果這適用於您的 OPC UA 伺服器，您可以使用下列程序從 SiteWise Edge 閘道匯出 OPC UA 用戶端憑證。然後，您可以在 OPC UA 伺服器上匯入憑證。

**匯出來源的 OPC UA 用戶端憑證檔案**

1. 執行下列命令，以變更至包含憑證檔案的目錄。將 *sitewise-work* 取代為 *aws.iot.SiteWiseEdgeCollectorOpcua* Greengrass 工作資料夾的本機儲存路徑，並將 *source-name* 取代為資料來源的名稱。

   根據預設，Greengrass 工作資料夾在 Linux 上為 */greengrass/v2/work/aws.iot.SiteWiseEdgeCollectorOpcua*，在 上為 *C：/greengrass/v2/work/aws.iot.SiteWiseEdgeCollectorOpcua*Microsoft Windows。

   ```
   cd /sitewise-work/source-name/opcua-certificate-store
   ```

1. 此來源的 SiteWise Edge 閘道 OPC UA 用戶端憑證位於 `aws-iot-opcua-client.pfx` 檔案中。

   執行下列命令，將憑證匯出至名為 `aws-iot-opcua-client-certificate.pem` 的`.pem` 檔案。

   ```
   keytool -exportcert -v -alias aws-iot-opcua-client -keystore aws-iot-opcua-client.pfx -storepass amazon -storetype PKCS12 -rfc > aws-iot-opcua-client-certificate.pem
   ```

1. 將憑證檔案 `aws-iot-opcua-client-certificate.pem`，從 SiteWise Edge 閘道傳輸到 OPC UA 伺服器。

   若要這麼做，您可以使用一般軟體，例如 `scp` 程式來傳輸使用 SSH 通訊協定的檔案。如需詳細資訊，請參閱 *Wikipedia* 上的[安全複製](https://en.wikipedia.org/wiki/Secure_copy)。
**注意**  
如果您的 SiteWise Edge 閘道在 Amazon Elastic Compute Cloud (Amazon EC2) 上執行，而且您第一次連線到它，您必須設定先決條件才能連線。如需詳細資訊，請參閱 *Amazon EC2 User Guide* 中的 [Connect to your Linux instance using SSH](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-to-linux-instance.html)。

1. 在 OPC UA 伺服器上匯入憑證檔案 `aws-iot-opcua-client-certificate.pem`，以信任 SiteWise Edge 閘道。步驟可能有所不同，取決於您使用的來源伺服器。請參閱伺服器文件。