This is really embarassing
on virtually any site on the internet,
window.crypto.subtle
returns
SubtleCrypto {} __proto__: SubtleCrypto
in the chrome console (v61 (Official Build) (64-bit))
except for
my webpage, and blank.org
where
window.crypto.subtle
returns
undefined
according to https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle it's a read-only property that should always return a SubtleCrypto object.
what could I have done, or what has blank.org done that it could possibly not?
ps: in firefox it seems to work as intended on both my site and blank.org
subtle. Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers. The Crypto. subtle read-only property returns a SubtleCrypto which can then be used to perform low-level cryptographic operations.
The digest() method of the SubtleCrypto interface generates a digest of the given data. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.
The window. crypto property returns a Crypto object which is associated with the global object. This object allows web pages to run various cryptographic operations on the browser side. It has one property, which is the subtle property.
According to the spec (via Github issues) a la this Google page for WebCrypto:
crypto.subtle is supposed to be undefined in insecure contexts
check your URL's
if it is https://localhost:PORT
or 0.0.0.0:port
or 127.0.0.0:port
change it to proper hostname URL something like http://localhost:PORT
worked for me! Thanks @Zmart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With