Windows Service hosted WCF over HTTPS

青春壹個敷衍的年華 提交于 2019-11-28 21:19:42
Ladislav Mrnka

I think you are connecting two different settings. Netsh can be used to add certificate for SSL but also to allow application listening on given port without running under admin account. The exception targets second setting. I haven't seen it before but I assume that you have already registered this port for HTTP so lets try to use (and register) HTTPS on another port or replace previous registration.

Edit:

Open command prompt with elevated privileges (As Admin). First check if SSL cert is assigned to correct port:

netsh http show sslcert

Than check if HTTP listening is registered on that port by calling:

netsh http show urlacl 

If so use following command to remove that registration:

netsh http delete urlacl url=http://+:54321/MyService

Add registration again to support listening on HTTPS:

netsh http add urlacl url=https://+:54321/MyService user=domain\userName

Where user is account used to run your Windows service. If it ia a local account use only userName.

Note: Under https, it appears the wildcard must be used in the urlacl. We cannot write https://localhost:8733/... to match Visual Studios default urlacl for http. This probably makes sense since the requested hostname isn't available until after decryption.

Different apparent cause, but same symptom, for others who find there way to this post.

I ran an application that had "always worked", and after various (not logged since I was not expecting issues) combinations of running it via remote desktop or locally, logging in and out, and replacing it with a recompiled but otherwise identical version with a different version number I got the same "Another application has already registered this URL ...blah, blah".

Apparently (?) the registration was specific to the instance that ran, and persisted across shutdowns of that application. (?) In any case the old Windows adage, "when in doubt reboot" took care of it. With no changes to the app itself it then ran with no complaints. It may be that de-registering, etc., would also have worked. This was under Windows 10 - I have never seen this with earlier versions of Windows.

Run the Visual Studio in Run as administrator mode Close the Visual studio application and re open it in administrator mode, That's enough the error is gone. HTTP errors occur when you are running the Visual studio in non admin mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!