使用JavaScript的JSON Web密钥的加密密钥

编程入门 行业动态 更新时间:2024-10-24 10:18:48
本文介绍了使用JavaScript的JSON Web密钥的加密密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是JavaScript或GatewayScript的新手.我有一个需要将.pem(位于DataPower中local:///cert下或可以添加到加密对象中)的内容转换为JWK的要求.

I am a newbie in JavaScript or GatewayScript. I have a requirement where I need to convert the content of a .pem (which is in DataPower under local:///cert or can be added into a crypto object) to JWK.

任何人都可以帮助我了解如何开发JavaScript的起点

Could anyone help me with the starting point on how to develop a javascript to

  • 从DataPower引用加密密钥对象(示例加密密钥) 对象JWKCryptoCertObj)
  • 解密加密密钥对象(示例 JWKCryptoCertObj.pem)
  • 将密钥的内容转换为JSON Web密钥(jwk.readCertificate())
  • refer the crypto key object from DataPower (example crypto key object JWKCryptoCertObj)
  • Decrypt the crypto key object (example JWKCryptoCertObj.pem)
  • Convert the content of the key to JSON Web Key (jwk.readCertificate())
  • 到目前为止,我已经知道jwk.readCertificate()可以帮助我将密钥对象转换为JWK.

    So far I have got to know that jwk.readCertificate() can help me to convert a key object to a JWK.

    我已经尝试了以下代码来获取它:

    I have tried the below piece of code to fetch it:

    var jwk = require('jwk'); var myJWK = jwk.readCertificate('cerjwk'); console.log(myJWK);

    var jwk = require('jwk'); var myJWK = jwk.readCertificate('cerjwk'); console.log(myJWK);

    但是,我在DataPower中遇到以下错误:

    However, I get the below error in DataPower:

    3:13:17 AM mpgw error 1277869681 error 0x00d30003 mpgw (PortTest): Rejected by filter; SOAP fault sent 3:13:17 AM multistep error 1277869681 request 0x80c00009 mpgw (PortTest): request PortTest_Policy_rule_1 #2 gatewayscript: Transforming the content of INPUT. The transformation local:///jwk.js is applied. The results are stored in testop. failed: Internal Error 3:13:17 AM gatewayscript error 1277869681 request 0x85800007 mpgw (PortTest): GatewayScript processing Error 'Error: Named certificate 'cerjwk' not found In file 'gatewayscript:///modules/jwk.js' line:428, stack:Error: Named certificate 'cerjwk' not found at Object.readCertificate (gatewayscript:///modules/jwk.js:428:18) at Object. (local:///jwk.js:5:17) at Script.execute (gatewayscript:///datapower.js:155:24) at Object. (gatewayscript:///datapower.js:582:55)' 3:13:17 AM crypto error 1277869681 request 0x8580005c mpgw (PortTest): Named certificate 'cerjwk' not found

    有人可以在这里帮助我解决这个问题吗?在此先感谢!

    Could anyone help me with the issue here? Thanks in advance!!

    推荐答案

    无需转换证书.只需将其添加到Crypto Key对象中,然后在调用中使用该对象的名称(例如"crykey-my-key")即可,例如:

    There is no need to convert the certificate. Just add it into a Crypto Key object and use the name (e.g. "crykey-my-key") of the object in the call, e.g.:

    const jwk = require('jwk'); const myKeyJWK = jwk.readCertificate('crykey-my-key');

    更多推荐

    使用JavaScript的JSON Web密钥的加密密钥

    本文发布于:2023-11-13 01:45:58,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1583073.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:密钥   JavaScript   JSON   Web

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!