Search code examples
c#.nethttpsmicrosoft-dynamicsunified-service-desk

WCF / USD / Dynamics 365: SchUseStrongCrypto loses effect after some time


I know this may seem an old question, but I don't think someone had the same problem in history.

I send a request to Dynamics 365 version 9 to IOrganizationService.Create, and the test is repeatable after what seems to be a dozen of times. At a certain point it doesn't work anymore and I have to restart USD.

The error I get is:

Exception detail:Error during HTTP request to https://xxxxxxxx.api.crm4.dynamics.com/XRMServices/2011/Organization.svc/web?SDKClientVersion=9.0.9002.0. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.  
Server stack trace: 
   in System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
   in System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   in System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   in System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   in System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   in System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   in System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   in System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   in System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   in Microsoft.Xrm.Sdk.IOrganizationService.Create(Entity entity)
   in Microsoft.Xrm.Sdk.WebServiceClient.WebProxyClient`1.ExecuteAction[TResult](Func`1 action)
   in Microsoft.Xrm.Sdk.WebServiceClient.OrganizationWebProxyClient.CreateCore(Entity entity)
   in CustomHostedControls.HiddenController.DoAction(RequestActionEventArgs args)
   in Microsoft.Uii.Csr.Aif.HostedApplication.HostedWpfControl.HandleRequestAction(Object sender, RequestActionEventArgs args)

I already verified all these conditions:

  • Test machine is Windows 7 Professional Version 6.1 Build 7601 Service Pack 1, 64 bit
  • SchUseStrongCrypto is set to 1 both under HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 and HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319
  • The exe is Unified Service Desk 3.2, which targets ".NETFramework,Version=v4.6.2"
  • This software has dlls compiled to target ".NETFramework,Version=v4.5.2"
  • In my UnifiedServiceDesk.exe.config I have: <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>

What else I am supposed to check?

Thank you


Solution

  • Somewhere in code I had a line like this:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;

    Solved with this:

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls12;

    Optimal solution would be to isolate code in an appdomain, anyway.