Network-related errors when using secure protocols


Description

In certain situations, the Sitecore Experience Platform attempts to make a web request to itself. For example, the Content Editor calls the keepalive.aspx page, or EXM renders an email message body.

Depending on your IIS or Windows settings, you can disable certain SSL protocols that are used by the .NET framework. This can lead to errors such as:

The underlying connection was closed: An unexpected error occurred on a send.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

Solution

To resolve the issue, you must change the System.Net.ServicePointManager.SecurityProtocol property to use updated protocols. For example:

  1. Create a custom processor to update the SecurityProtocol property with new protocols. For example:
    public void Process(PipelineArgs args)
    {
    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Ssl3;
    }
  2. Add this processor to the <initialize> pipeline in the Web.config file (or the Sitecore.config file for Sitecore XP 8.1 and later):
    <pipelines>
      <initialize>   ... <processor type="<your-processor-class-name, your-assembly-name" />
    </initialize>