none
WCF Service error : An error occurred when verifying security for the message RRS feed

  • Question

  • We have WCF service with ‘WSHttpBinding', with reliable session on HTTPS, hosted on IIS. When client communicates from different machine with different date time, it gives below error:

    {"An error occurred when verifying security for the message."} An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail.

    We need to make this communication even there is a timezone difference. Any help would be highly appreciated.

    Friday, August 11, 2017 6:41 AM

All replies

  • Hi Parsottam,

    >> We need to make this communication even there is a timezone difference.

    For different timezone, I think you could try to implement a custom binding for client and service with MaxClockSkew property.

    A simple code like below:

    public static Binding CreateCustomBinding(TimeSpan clockSkew)
    {
        WSHttpBinding standardBinding = new WSHttpBinding(SecurityMode.Message, true);
        CustomBinding myCustomBinding = new CustomBinding(standardBinding);
        SymmetricSecurityBindingElement security =
            myCustomBinding.Elements.Find<SymmetricSecurityBindingElement>();
        security.LocalClientSettings.MaxClockSkew = clockSkew;
        security.LocalServiceSettings.MaxClockSkew = clockSkew;
        // Get the System.ServiceModel.Security.Tokens.SecureConversationSecurityTokenParameters 
        SecureConversationSecurityTokenParameters secureTokenParams =
            (SecureConversationSecurityTokenParameters)security.ProtectionTokenParameters;
        // From the collection, get the bootstrap element.
        SecurityBindingElement bootstrap = secureTokenParams.BootstrapSecurityBindingElement;
        // Set the MaxClockSkew on the bootstrap element.
        bootstrap.LocalClientSettings.MaxClockSkew = clockSkew;
        bootstrap.LocalServiceSettings.MaxClockSkew = clockSkew;
        return myCustomBinding;
    }

    # How to: Set a Max Clock Skew

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-set-a-max-clock-skew

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 14, 2017 2:04 AM