Comment by jefftk

4 years ago

It is documented [1] as only being available in secure contexts, which is normally https:// but does include file:// urls. Testing now, it works for me in Chrome, Safari, Brave, and Firefox.

If you put:

    <script>
      window.crypto.subtle.generateKey(
        {name: "ECDSA", namedCurve: "P-256"},
        false, ["sign", "verify"])
      .then(function(key){alert(key.publicKey)})
    </script>

in a local HTML file and visit it in your browser, all four browsers alert with "[object CryptoKey]".

[1] https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subt...

[2] https://developer.mozilla.org/en-US/docs/Web/Security/Secure...