I have a issue loading x509 certificate in net.core. I use the following code :
var bytes = File.ReadAllBytes(certificatePath);
var cert = new X509Certificate2(bytes);
and I get the following error :
Cannot find the requested object
If I change the code to :
var cert = new X509Certificate2();
cert.Import(_path);
I get thrown the following exception:
System.PlatformNotSupportedException : X509Certificate is immutable on this
platform. Use the equivalent constructor instead.
Other useful infos:
- Certificate_path": "C:\XYZ\Documents\XYZ\rsakey.txt
- Certificate and alghoritm info : RSA encryption strategy with mode ECB, padding PKCS1Padding and KeyLength 1024 is used to encrypt data at client side.
I discovered that I'm trying to pass a public key instead of a certificate but I don't know how can I generate certificate in c# from a public key. How can I solve this problem? Thanks