Change certs of WCF service on the fly, no downtime

谁说我不能喝 提交于 2020-01-05 03:34:06

问题


I've been researching a way of changing IssuedTokenAuthentication certs in a WCF after the service has started listening to its connection. I know that I could change the certs just by going into the web.config and then resetting the service so it loads the new settings, but I need to do it on the fly without any downtime.

I know that I could get the current ServiceHost instance by doing:

ServiceHost host = (ServiceHost)OperationContext.Current.Host;

and then I could access its service certs through:

host.Credentials.IssuedTokenAuthentication.KnownCertificates

but that doesn't work once the service is running, as the list of certificates returned becomes ReadOnly.

The other way I've seen is to go the Description route, but that seems to be read only as well:

host.Description.Behaviors.Find<ServiceCredentials>().IssuedTokenAuthentication.KnownCertificates;

The same cert list would be found in the following location of the web.config:

<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>              
          <serviceCredentials>
              <serviceCertificate/>

I'm stuck at this point, I don't think there's actually a way to access a writable list of those certs. Is that true, can anybody confirm, or is there a way?

Thanks!

来源:https://stackoverflow.com/questions/5559217/change-certs-of-wcf-service-on-the-fly-no-downtime

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