Hi,
I have an Outlook (2013) AddIn written in C#, which worked fine when using it with TLS 1.0/1.1 enabled. However, when disabling TLS 1.2 on Exchange Server, the code does not work anymore. The code did not change when TLS 1.0/1.1 was disabled.
The error message is: "The request failed .The underlying connection was closed: An unexpected error occurred on a receive."
Here is a code snippet:
this.service = new ExchangeService();
this.service.UseDefaultCredentials = true;
if (this.registryValues.ContainsKey("ExchangeUri"))
{
this.service.Url = new Uri(this.registryValues["ExchangeUri"]);
}
string distributionGroup = string.Empty;
if (this.registryValues.ContainsKey("VerifierDistributionList"))
{
distributionGroup = this.registryValues["VerifierDistributionList"];
}
try
{
ExpandGroupResults myGroupMembers = this.service.ExpandGroup(distributionGroup);
// checking, if my users EmailAddress is in the group
catch (System.Exception e)
{
//Showing the exception in a message box
}
I am using .NET 4.8 to build the project, which is also installed on the Exchange Server. The Exchange Server itself is Exchange Server 2013 with the latest update (CU23).
To setup TLS 1.2 we followed this post:
https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-server-tls-guidance-part-1-getting-ready-for-tls-1-2/ba-p/607649
https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-server-tls-guidance-part-2-enabling-tls-1-2-and/ba-p/607761
https://techcommunity.microsoft.com/t5/exchange-team-blog/exchange-server-tls-guidance-part-3-turning-off-tls-1-0-1-1/ba-p/607898
This looks like an issue on how I created the ExchangeService object, but I'm still wondering why it worked before. I tried adding System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault; (which should be the default anyway for .NET 4.8) or System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; but for both options the error occurs. Interestingly, I can force the same error, when I use SystemDefault, when TLS 1.0/1.1 are enabled.
Do I need to change some definition in my code or is it an issue with Outlook 2013?
Best Regards,
Gianluca