Edit:
Turns out that Bouncy Castle is fully managed. This question explains how to create a .pfx file with a private and public part of the certificate.
For an application that I'm writing in C# (targeting .net Standard 2.0/.net Core 2.x), I want to create X509Certificates with a private key, basically a self-signed HTTPS certificate with RSA and SHA256 or SHA512.
I know how to do this through the Windows API with CertCreateSelfSignCertificate
from Crypt32.dll, but I wonder if there is a 100% managed solution for this?
This is for dev use, so the fact that the cert isn't trusted is no issue. I don't want to execute an external application (openssl), and even though .net Core has some native crypto bindings, I'm looking for fully managed.