Featured post
c# - Programatically import cert into IIS? -
i have .pem certificate ssl, want distribute web application in msi (has run on clients' computers). need import (into credentials store?) , tell site bindings use it. how can in code? i've discovered microsoft.web.administration, not sure go there …
this in iis7 btw.
edit: goal here have web application customers can run on intranets. acts api iphone app. (maybe isn't best design we're locked in now.) customer installs msi, , voila, have web service. there needs password authentication between iphone , web service; simplest way seemed to in https. made self-signed cert.
i'm aware redistributing single cert bad idea, we're trying defeat casual hackers here … going intranet , businesses only, seems unlikely going doing crazy, , api severely restricts amount of bad things able database anyways.
so there go, goal have password authentication on intranet web app, one-click(ish) installation. :-d
the answer, dear readers, this:
// assume 'site' set site via // site site = mgr.sites.add(sitename, directory, 443); x509store store = new x509store(storename.my, storelocation.localmachine); store.open(openflags.openexistingonly | openflags.readwrite); // here, directory install dir, , (directory)\bin\certificate.pfx cert file is. // 1234 password certfile (exported iis) x509certificate2 certificate = new x509certificate2(directory + @"\bin\certificate.pfx", "1234"); store.add(certificate); var binding = site.bindings.add("*:443:", certificate.getcerthash(), store.name); binding.protocol = "https"; store.close();
thanks random thread: http://forums.iis.net/t/1163325.aspx
- Get link
- X
- Other Apps
Comments
Post a Comment