Amazon SDK for JavaScript V3 API 参考指南详细描述了 Amazon SDK for JavaScript 版本 3 (V3) 的所有API操作。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
在 Node.js 中注册证书包
Node.js 的默认信任存储包含访问 Amazon 服务所需的证书。在某些情况下,最好只包括一组特定的证书。
在本示例中,使用磁盘上的特定证书创建
https.Agent
,除非提供指定的证书,否则它会拒绝连接。然后,DynamoDB 客户端将使用新创建的 https.Agent
。
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; import { NodeHttpHandler } from "@smithy/node-http-handler"; import { Agent } from "https"; import { readFileSync } from "fs"; const certs = [readFileSync("/path/to/cert.pem")]; const agent = new Agent({ rejectUnauthorized: true, ca: certs }); const dynamodbClient = new DynamoDBClient({ requestHandler: new NodeHttpHandler({ httpAgent: agent, httpsAgent: agent }) });