c# - Convert FileUpload to X509Certificate2 -


how can convert uploaded file x509certificate2 variable?

i have tried using following code not working:

public bool haspublickey(fileupload file) {     bool check = false;      try     {          x509certificate2 cert = (x509certificate2)file.postedfile.inputstream;     }     catch(exception)     {          check = false;     }  } 

if uploaded file valid certificate should have @ constructor or import method in x509certificate2 class.

you'll see need this:

var filelength = file.postedfile.contentlength; var certdata = new byte[filelength];  file.filecontent.read(certdata, 0, filelength);  var cert = new x509certificate2(certdata); 

(code not verified it, or similar, should work).


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -