NestJs SSL:错误:06065064:数字信封例程:EVP_DecryptFinal_ex:解密失败

3

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

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

以下是我在 NestJS 中使用它的方式。

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.
1个回答

3
当我以不同的方式生成证书时,它开始正常工作。我使用以下命令来生成证书。
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://dev59.com/9GEh5IYBdhLWcg3wTBxc#24283204

这是一个关于如何在Python中使用SMTP发送电子邮件的示例代码。首先,您需要导入SMTP和MIMEText模块,然后设置发送方,接收方,主题和正文。最后,使用SMTP对象的sendmail方法将电子邮件发送到服务器。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接