- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正尝试按如下方式导入 ECDSA 公钥:
ua8 = new Uint8Array( [48, 86, 48, 16, 6, 4, 43, 129, 4, 112, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 124, 78, 186, 4, 136, 215, 226, 113, 200, 80, 93, 199, 105, 63, 47, 60, 193, 162, 180, 226, 160, 164, 9, 183, 122, 42, 97, 201, 99, 128, 54, 227, 193, 220, 229, 75, 186, 223, 201, 227, 229, 159, 159, 67, 205, 3, 126, 74, 211, 202, 122, 66, 185, 150, 74, 152, 192, 177, 81, 155, 106, 237, 212, 146] );
crypto.subtle.importKey( "spki", ua8, { name: "ECDSA", namedCurve: "P-256", }, false, ["verify"] );
在 Firefox 中,这很好用,但在 Chrome 中我得到一个 DOMException。
我希望它能在两种浏览器中运行。我该如何解决?
最佳答案
根据 the Chromium WebCrypto documentation :
Chromium's WebCrypto implementation supports all of the key formats - "raw", "spki", "pkcs8", "jwk", with the following caveats:
- There are differences in DER key format handling between Web Crypto implementations. Where possible for compatibility prefer using "raw" keys or "jwk" which have better interoperability.
- When importing/exporting "spki" and "pkcs8" formats, the only OIDs supported by Chromiumare those recognized by OpenSSL/BoringSSL.
特别是,它说:
- Importing ECDH keys does not accept id-ecDH. The OID must instead be id-ecPublicKey (This can cause problems importing keys generated by Firefox; use "raw" EC keys as a workaround; Chromium in this case is not spec compliant)
(错误跟踪器链接给我一个 500 内部服务器错误,但这可能是暂时的。)
Looking at your key in an ASN.1 decoder ,它包含以下数据:
SEQUENCE (2 elem)
SEQUENCE (2 elem)
OBJECT IDENTIFIER 1.3.132.112
OBJECT IDENTIFIER 1.2.840.10045.3.1.7 prime256v1 (ANSI X9.62 named elliptic curve)
BIT STRING (520 bit) 0000010001111100010011101011101000000100100010001101011111100010011100…
对象标识符1.3.132.112正是Chrome无法识别的“id-ecDH”标识符。对于它的值(value),a key exported from Chrome取而代之的是 OID 1.2.840.10045.2.1(“ecPublicKey”)。
正如链接的文档页面所建议的那样,作为一种变通方法,您可能希望从“spki”格式切换到“原始”格式(或切换到基于 JSON 的 "jwk")。
关于javascript - Chrome 中的 crypto.subtle.importKey 抛出 DOMException,而 Firefox 运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45867655/
我正在尝试使用 Google 的 Material 设计。 我在下面有一个组件,其路径是 epimss_design/lib/component/menu/main-menu-form.html; e
我在导航文档对象以删除特定节点时遇到 DOMException.HIERARCHY_REQUEST_ERR,在谷歌搜索此错误代码后,它说: “HIERARCHY_REQUEST_ERR:如果此节点的类
我已经使用 React JS 为 service worker 注册了 JS 文件。但是,当我尝试注册 periodic-background-sync 时出现错误。我需要在谷歌浏览器中进行任何设置吗
我在 Polymer 2 中有一个简单的 todo aap。它工作得很好,但是当我从 Polymer 目录添加元素时,我收到以下错误?还有纸张输入不能正常显示?检查屏幕截图。一切都很好我不知道为什么这
我一直在查询 websql 数据库表。在这里,插入和删除语句工作正常。 但是当我尝试执行 findAll 查询时,本质上是'select * from myTable',它返回一个带有 DOMExce
我刚刚动态创建了视频对象,然后在将视频对象附加到文档中之前添加了 2 个属性,例如 source 和 muted,最后使用方法 play() 播放添加的视频,如下所示。 let v = documen
在“我的应用程序”中,我想将节点从一个文档复制到另一个文档。 这是代码。 Element entryElement, operationElement; for (int i = 0; i < eve
我正在尝试通过替换其中的某些元素来使用 DOM 修改 XML 文档,但出现以下异常: 03-10 10:49:20.943: W/System.err(22584): org.w3c.dom.D
我正在使用 native-crypto 包,它是一个用于跨平台加密的 API(例如 web 和 node.js)。 let crypto = require("native-crypto"); 我已经
Chrome 会阻止自动播放音频/视频。我找到了自动播放视频的解决方案,但我的用例需要自动播放音频。这是我的代码: let audio = new Audio('music/test.mp3'); a
我正在尝试加载音频,但遇到了两个错误,但是一切都很好,并且来源是正确的。 错误: GET http:// localhost:4200 / src / assets / sound / welcome
每当我运行此代码时 var blob = new Blob(["ninja.mp3"], {type:"audio/mp3"}); var audio = new Audio(URL.createOb
我正在尝试使用 C3 在我的 React 项目中呈现图表。 问题 我所做的是动态生成一个 id (UUID) 并将其附加到我的图表组件中的 div。然后,在组件在 componentDidMount
您好,我在 Chrome 中播放音频时遇到异常。 这是我播放音频的功能 $(document).ready(function () { generateAlarm(); }); functio
我正在开发一个 WebAudio 应用程序,它需要 AudioWorklets 并且需要来自许多不同脚本的函数以用于 process() 函数。因此,我尝试使用 import 命令在 processo
我正在学习本教程,该教程教授 polymer 元件的安装: https://www.polymer-project.org/3.0/start/toolbox/add-elements 运行 npm
我有Video Player 。但是当我改变质量时它给出了这个错误 Uncaught (in promise) DOMException: The play() request was interru
我正在尝试将加密数据从服务器发送到客户端,并使用window.crypto.subtle.decrypt()对其进行解密。但我有一个没有描述的错误。我该如何修复它? node.js 服务器代码: co
我收到这个错误: Uncaught (in promise) DOMException: lockOrientation() is not available on this device. co
我正在使用 indexedDB(通过 npm 的 idb 包装器)来存储表示音频 channel 数据的 2D Float32 数组。它在一段时间内工作正常,但是,当其中一个数组的长度达到大约 166
我是一名优秀的程序员,十分优秀!