gpt4 book ai didi

javascript - NestJs SSL : error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt

转载 作者:行者123 更新时间:2023-12-04 22:35:17 29 4
gpt4 key购买 nike

我已经使用以下命令生成了证书。

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

我在 nest js 中使用它如下。

const httpsOptions = {
key: fs.readFileSync('./secrets/key.pem'),
cert: fs.readFileSync('./secrets/cert.pem'),
};
const app = await NestFactory.create(AppModule, {
httpsOptions,
});
await app.listen(3000);

我遇到了以下错误。我在这里做错了什么?

(node:4868) UnhandledPromiseRejectionWarning: Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt
at Object.createSecureContext (_tls_common.js:149:17)
at Server.setSecureContext (_tls_wrap.js:1323:27)
at Server (_tls_wrap.js:1181:8)
at new Server (https.js:66:14)
at Object.createServer (https.js:91:10)
at ExpressAdapter.initHttpServer (C:\my-project\node_modules\@nestjs\platform-express\adapters\express-adapter.js:97:37)
at NestApplication.createServer (C:\my-project\node_modules\@nestjs\core\nest-application.js:68:26)
at NestApplication.registerHttpServer (C:\my-project\node_modules\@nestjs\core\nest-application.js:51:32)
at new NestApplication (C:\my-project\node_modules\@nestjs\core\nest-application.js:35:14)
at NestFactoryStatic.create (C:\my-project\node_modules\@nestjs\core\nest-factory.js:35:26)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at bootstrap (C:\my-project\server\main.ts:25:18)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4868) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 9)
(node:4868) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

最佳答案

当我以不同的方式生成证书时,它开始工作了。我在下面使用生成证书。

openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem
openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out server.crt

并如下使用它。

var options = {
key: fs.readFileSync('./key.pem', 'utf8'),
cert: fs.readFileSync('./server.crt', 'utf8')
};

来源:https://stackoverflow.com/a/24283204/9263418

关于javascript - NestJs SSL : error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67446485/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com