我试图通过AWS安全中心- APIGateway.2下的安全性遵从性检查。2 API网关REST API阶段应该配置为使用SSL证书进行后端身份验证。
我做了什么?
const nestApplicationOptions: NestApplicationOptions = {
httpsOptions: {
ca: [fs.readFileSync('secrets/apig-cert.pem')],
requestCert: true,
rejectUnauthorized: true,
},
};
const expressApp = express();
const adapter = new ExpressAdapter(expressApp);
const app = await NestFactory.create<NestExpressApplication>(
AppModule,
adapter,
nestApplicationOptions,
);
...
await app.init();
await awsServerlessExpress.createServer(expressApp);预期行为:
目前的行为:
我不知道这里缺少了什么。我认为我使用NestFactory.create或awsServerlessExpress.createServer的方式有些可疑。
额外信息:
参考链接-
发布于 2021-11-15 18:25:57
@kartoon --如果你注意文档,上面写着
Before configuring a backend HTTPS server to verify the client SSL certificate of API Gateway, you must have obtained the PEM-encoded private key and a server-side certificate that is provided by a trusted certificate authority.
您的服务器端代码应该将私钥配置为证书,如果证书将提供给API网关。如果您查看AWS文档中提供的示例表达式代码,下面是我正在讨论的两行代码。
key: fs.readFileSync('server-key.pem'),
cert: fs.readFileSync('server-cert.pem'), 在这种情况下,您的代码应该类似于
const nestApplicationOptions: NestApplicationOptions = {
httpsOptions: {
ca: [fs.readFileSync('CA-SIGNER-CERT.pem')],
cert: [fs.readFileSync('PUBLIC-CERT.pem')],
key: [fs.readFileSync('PRIVATE-KEY.key')],
requestCert: true,
rejectUnauthorized: true,
},
};https://stackoverflow.com/questions/69449536
复制相似问题