问题
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