c# - Certificate Install Security Warning Workaround? -


i have c# 4.0 code attempts install ca (.der encoded) certificate "trusted root certification authorities" store current (my) user. little console app runs silently against other stores, store gui popup comes "you install certificate certification authority... windows cannot validate certificate from..... want install certificate?"

this messagebox problem because idea automatically deploy app msi , silently right certs in right place. having modal box kill automated deployment.

how can installation done without deployment-breaking messagebox?

it can sound not logical, have no warning should add certificate not root certificate store of current user, root of local machine instead. can easy verify that

certmgr.exe -add -c t.cer -s -r currentuser root 

produce security warning, but

certmgr.exe -add -c t.cer -s -r localmachine root 

not.

so if want import certificate in .net corresponding code following

using system; using system.security.cryptography.x509certificates;  namespace addcerttorootstore {     class program {         static void main (string[] args) {             x509store store = new x509store (storename.root,                                              storelocation.localmachine);             store.open (openflags.readwrite);             x509certificate2collection collection = new x509certificate2collection();             x509certificate2 cert = new x509certificate2 (@"c:\oleg\t.cer");             byte[] encodedcert = cert.getrawcertdata();             console.writeline ("the certificate added root...");             store.add (cert);             console.writeline("verify, certificate added successfully");             console.readkey ();             console.writeline ("the certificate removed root");             store.remove (cert);             store.close ();         }     } } 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

c# - How to execute a particular part of code asynchronously in a class -

c# - Asterisk click to call -