Open AgrYpn1a opened 2 years ago
Same issue here. If you simply try and log(SwanRuntime.OS) which look to be happening in the AutoRegister setter, it results in a "TypeInitializationException: The type initializer for 'Swan.SwanRuntime' threw an exception"
I just transferred this issue from EmbedIO, since this is evidently an issue with Swan.Lite
version 3.
Looking at the source code, I can't understand where this exception comes from. All SwanRuntime
does at initialization is create some apparently innocent objects. Can anyone shed some light?
Are they trying to use HTTPS on Mac?
In my case it was Unity on Windows 10.
The issue is using Assembly.GetEntryAssembly()
here, which can be null in various cases (e.g. unit tests).
https://github.com/unosquare/swan/blob/4b33e5f943a4513124243c0fcf8e9b9f7503b858/src/Swan.Lite/SwanRuntime.cs#L37
In my case I found I didn't actually need to use AutoRegisterCertificate
, my problem was that I was trying to use WithCertificate
with a certificate that didn't have a private key attached (.crt) - generating the right type of certificate file (.pfx) made it work without needing to touch the system certificate store.
I ended up writing a C# wrapper around https://github.com/yhirose/cpp-httplib since none of the .NET solutions I've tried worked.
Hey,
We already discussed this in the previous post but it remained unresolved. I wonder if you could help. I am getting a nullptr exception here when trying to load a certificate. I've logged the certificate, and it's loaded correctly.