Some devices send email and other devices always fail with error SslHandshakeException
marcozakaria opened this issue ยท 6 comments
App is made with Unity, Some devices sends email and other devices always fail with error SslHandshakeException, checked date and time on both devices are correct and we dont use VPN
- App is made with Unity engine and runs only on ipad with Ipad OS 17
- .NET Framework: 4
- MailKit Version: 4.7.1.1
Exception
Rethrow as SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.
this is image from logs of devices that fails , i checked thr FAQ link and didnt find thing usefull to my case
Well, the first step is to figure out which of those issues it is.
Create a method like this:
bool DebugCertificateValidationCallback (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
if (sslPolicyErrors == SslPolicyErrors.None)
return true;
Console.WriteLine ($"sslPolicyErrors = {sslPolicyErrors}");
return false;
}
Then, set this callback method on the client like this:
client.ServerCertificateValidationCallback = DebugCertificateValidationCallback;
Now try connecting and see what the value of sslPolicyErrors
is. From there, you can start debugging into the chain (which has error codes for each node in the chain).
Thanks @jstedfast it didnt give any errors
but when i changed await client.ConnectAsync(SMTPClient, SMTPPort, true);
to client.Connect(SMTPClient, SMTPPort, true);
it worked and sent email, do you know why async method doesn't work ?
using non async method hangs application until the request is finished.
The sslPolicyErrors
value was None
? Are you 100% sure? That doesn't make sense.
Yes sslPolicyErrors
value was None
one note in unity editor on windows or mac both Connect
and ConnectAsync
works fine, only build on Ipad ConnectAsync
doesnt work
It could be Unity bug but i am not sure
That does sound like potentially a Unity bug.
It works fine for me on macOS using the dotnet runtime.
Normal Connect
works fine for our needs now on ipad
Thank you for providing help and support @jstedfast