ssl - Getting Certificate of A WebSite via C# -
i can display certificate code. question how can store or write certificate in file?
using system.security; using system.security.cryptography; using system.security.cryptography.x509certificates; //do webrequest info on secure site httpwebrequest request = (httpwebrequest)webrequest.create("https://mail.google.com"); httpwebresponse response = (httpwebresponse)request.getresponse(); response.close(); //retrieve ssl cert , assign x509certificate object x509certificate cert = request.servicepoint.certificate; //convert x509certificate x509certificate2 object passing constructor x509certificate2 cert2 = new x509certificate2(cert); string cn = cert2.getissuername(); string cedate = cert2.getexpirationdatestring(); string cpub = cert2.getpublickeystring(); //display cert dialog box x509certificate2ui.displaycertificate(cert2);
you can call cert.export(...)
byte[]
can write file.
Comments
Post a Comment