The SSL connection could not be established, see inner exception. The remote certificate is invalid according to the validation procedure
Hello
Installed the Microsoft.Exchange.WebServices.NETStandard 1.1.3 package via nuget, the letter via the Exchange service is successfully sent via the Windows OS Under Linux, Debian no longer works.
I had to download the weight of the project source and connect it to the project. In this case, sending does not work under Windows and under Linux.
I use a component under Debian to connect to Exchang server. Debian in docker. I use Core 2.2 Sending an email.
public void Send(MailMessage mailMessage)
{
var service = GetService();
if (service != null)
{
EmailMessage emailMessage = new EmailMessage(service)
{
From = new EmailAddress(ewsConnection.MailBox),
Subject = mailMessage.Subject,
Body = mailMessage.Body,
};
if (mailMessage.Adresses != null)
{
foreach (var email in mailMessage.Adresses)
{
emailMessage.ToRecipients.Add(new EmailAddress(email));
}
}
emailMessage.Send();
}
}
private ExchangeService GetService()
{
ExchangeService service = null;
ExchangeVersion version;
if (Enum.TryParse<ExchangeVersion>(ewsConnection.Version, out version))
{
service = new ExchangeService(version);
service.Credentials = new WebCredentials(ewsConnection.Login, ewsConnection.Password);
service.Url = new Uri(ewsConnection.Host);
// Проверка сертификата
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
}
return service;
}
Submit Error:
The SSL connection could not be established, see inner exception. The remote certificate is invalid according to the validation procedure.
What can I do?
See also #25
ServicePointManager.ServerCertificateValidationCallback is not supported in .NET Core it seems even if documentation says .NET Core, particularly as this library now uses HttpClient.