|
I have been trying for a while to get the HttpListener to work with SSL (vs2005 on XP SP2) and finally i got a break through. All info i've found so far points to making a certificate and using httpcfg to bind the certificate to the given prefix endpoint. I followed instructions but still it would not work (see link below, this was most helpful):
http://answers.google.com/answers/threadview?id=735306
(btw, dont change 0.0.0.0: to your ip address, leave it as is ;)
So after looking into the MSDN docs some more and playing with the httpcfg tool i found i needed to not only bind the certificate to the endpoint but also to the application. You do this by passing the applications GUID to the set ssl command!!
Following are some commands i used to figure things out a bit:
httpcfg query ssl <-- get a list of bound certificates
and found the guid empty. So i deleted any bound certificates:
httpcfg delete ssl -i 0.0.0.0:90
Then re issued the httpcfg set ssl command and specified the GUID from my vs2005 projects AssemblyInfo.cs, under [assembly: Guid("xxx")] as in:
httpcfg set ssl -i 0.0.0.0:8585 -c "MY" -g {E27BC593-0E2b-4043-AA07-1DBAFD724990} <-- App GUID -h 99F065C41348FBFB261E959C1A76892E91176999 <-- Cert footprint
Then i reran my app and it worked (it complained about an invalid certificate, but it is a test certificate)!!
Now this is a bit interesting: I moved my certificate from LOCAL_MACHINE\Trusted Root Certification Authorities\Certificates into LOCAL_MACHINE\Personal\Certificates before i used httpcfg. This seems contrairy to previous advice of leaving it in Trusted Root store but i guess this is because im running on my dev machine, not prod server!!
I hope this sheds some light on using HttpListener with SSL.
cheers James
|