I am trying to use c# to generate a X509Certificate2
.
I came across this answer which is what I am looking for. But, that code is using absolute methods.
The method SetSignatureAlgorithm
has the following warning
Not needed if Generate used with an ISignatureFactory
Also, the code certificateGenerator.Generate(issuerPrivateKey, random)
has the following message
Use Generate with an ISignatureFactory
How can I create a ISignatureFactory
to fix these two warnings?
Will this work for you? This method generates a private key on the fly, signs it with a self-signed certificate and returns the cert and key as a PKCS#12 bundle (can be saved in a .pfx file if need be).