-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[wasm] Guid.NewGuid()
fails with Error occurred during a cryptographic operation.
in Interop.GetCryptographicallySecureRandomBytes(Byte* buffer, Int32 length)
with node < 19.x
#77927
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionWhen creating a new GUID in a .NET 7 WASM console app, I'm getting a runtime error. Reproduction Steps
Expected behaviorNo error expected. Actual behavior
Regression?No response Known WorkaroundsNo response Configuration
Other informationNo response
|
Still happening with dotnet 7.0.100 |
This works fine with https://dotnet.microsoft.com/en-us/download/dotnet/7.0 .
using System;
using System.Runtime.InteropServices.JavaScript;
Console.WriteLine ($"{Guid.NewGuid()}");
Console.WriteLine("Hello, Console!");
return 0;
public partial class MyClass
{
[JSExport]
internal static string Greeting()
{
var text = $"Hello, World! Greetings from node version: {GetNodeVersion()}";
return text;
}
[JSImport("node.process.version", "main.mjs")]
internal static partial string GetNodeVersion();
} @benjineering can you try with |
This issue has been marked |
@radical I did try with 7.0.100, but got the same error. However, I noticed you are using the latest version of Node. I had tried with Node v17.3.0 and v18.6.0 which both threw that same error, but using v19.1.0 (which you appear to have) seems to work. |
You are correct. With
.. and the same files with
|
Guid.NewGuid()
fails with Error occurred during a cryptographic operation.
in Interop.GetCryptographicallySecureRandomBytes(Byte* buffer, Int32 length)
with node < 19.x
Guid.NewGuid()
fails with Error occurred during a cryptographic operation.
in Interop.GetCryptographicallySecureRandomBytes(Byte* buffer, Int32 length)
with node < 19.xGuid.NewGuid()
fails with Error occurred during a cryptographic operation.
in Interop.GetCryptographicallySecureRandomBytes(Byte* buffer, Int32 length)
with node
< 19.x
Guid.NewGuid()
fails with Error occurred during a cryptographic operation.
in Interop.GetCryptographicallySecureRandomBytes(Byte* buffer, Int32 length)
with node
< 19.x
Guid.NewGuid()
fails with Error occurred during a cryptographic operation.
in Interop.GetCryptographicallySecureRandomBytes(Byte* buffer, Int32 length)
with node < 19.x
Secure solution for old Node would probably need some npm library with native module. For node above 15.0 you can do
Should we do that ^^ on behalf of the users ? @maraf For under NodeJS 15.0 simple and unsecure workaround is
|
For node 14.18.2 there is |
Description
When creating a new GUID in a .NET 7 WASM console app, I'm getting a runtime error.
Reproduction Steps
dotnet new wasmconsole
var guid = Guid.NewGuid();
before the console log statementdotnet build -c Debug
node .\bin\Debug\net7.0\browser-wasm\AppBundle\main.mjs
Expected behavior
No error expected.
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: