I've seen a lot of traffic regarding the X509CertificateLoader
on my website lately, so I guess people are struggling with fixing the deprecations on the constructor of X509Certificate2
(as I did, too).
So basically:
// from file
var cert = new X509Certificate2("./myfile.pfx");
// from byte array
var stream = new MemoryStream();
var cert = new X509Certificate2(stream.ToArray());
has become:
// from file
var cert = X509CertificateLoader.LoadCertificateFromFile("./myfile.pfx");
// from byte array
var stream = new MemoryStream();
var cert = X509CertificateLoader.LoadPkcs12(mem.ToArray(), null);
There are of course more overloads, but you will get the idea.
Cover picture by Marjan Blan
Top comments (0)