无法将加密密钥发送到 Express 服务器

问题描述

在客户端上,我使用 CryptoKeyPair API 生成 WebCrypto 对象。我想使用 fetch API 将此密钥对发送到我的快速服务器,但我在 req.body 中得到的只是一个空对象。为什么会这样?

生成密钥:

const keyPair = await crypto.subtle.generateKey(RsaOaepParams,true,["encrypt","decrypt"]);

POST 请求:

fetch('/',{
    method: 'POST',body: JSON.stringify(keyPair.publicKey),headers: {
      'Content-Type': 'application/json'
    },})

不,这不是 bodyParser 中间件的问题。我已经正确配置了它。 JSON.stringify(keyPair.publicKey) 本身正在将对象变为空

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)