c# - Is it possible to store RSACryptoServiceProvider in X509Certificate2 or X509Store? -




i have keypair provided me hardware device in form of rsaparameters can convert cryptoserviceprovider using following code , encrypt/decrypt/sign.

rsacryptoserviceprovider rsaprivkey = new rsacryptoserviceprovider(2048) { persistkeyincsp = false }; // rsaparameters rsaparam = rsaprivkey.exportparameters(true); // testing rsaprivkey.importparameters(rsaparam); 

i'm not allowed use file system store certificate , hardware device not available sometimes, store certificate in machine certificate store (certificates -> local computer -> personal)

as x509certificate2.privatekey document suggests, should able set private key of certificate , save store following

x509certificate2 cert2 = new x509certificate2(); cert2.privatekey = rsaprivkey;  x509store cstore = new x509store(storename.my, storelocation.localmachine); cstore.open(openflags.maxallowed); cstore.add(cert2); cstore.close(); 

however error m_safecertcontext invalid handle according this answer happening because properties of x509certificate2 not set, correct. cannot assign validity date, issuer, ... certificate.

question

is possible store rsacryptoserviceprovider in x509certificate2? if yes, missing steps?





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -