X509 compatible certificates are commonly used in various scenarios. Creating a new certificate usually involves using the makecert.exe or a specialized application (I prefer Portecle, it’s easy to use and free).
Creating certificates programmatically is also a common requirement. Although the base class library supports X509 infrastructure (System.Security.Cryptography.X509Certificates namespace), there is no easy way to create certificates with sole BCL. Fortunately, there is Bouncy Castle which contains all required APIs. Bouncy Castle is available on NuGet, adding it to your solution could just not be easier.
I can now link this with the BCL as the saved certificate is compatible with the System.Security.Cryptography.X509Certificates.X509Certificate2: