jstedfast / MailKit

A cross-platform .NET library for IMAP, POP3, and SMTP.

Home Page:http://www.mimekit.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

failed to run on android

ismlsmile opened this issue · comments

platform : .Net 8.0
The same code is ok on windows and linux, but when run on android, there is an error:
MailKit.Security.SslHandshakeException
Message=An error occurred while attempting to establish an SSL or TLS connection.

The server's SSL certificate could not be validated for the following reasons:
• The server certificate has the following errors:
• The certificate's revocation status could not be determined.
• An intermediate certificate has the following errors:
• Unable to determine revocation status due to network error

Source=MailKit
StackTrace:
at MailKit.Net.Pop3.Pop3Client.Connect(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken) in D:\src\MailKit\MailKit\Net\Pop3\Pop3Client.cs:line 1200
at MailKit.MailService.Connect(String host, Int32 port, Boolean useSsl, CancellationToken cancellationToken) in D:\src\MailKit\MailKit\MailService.cs:line 1058

This is expected behavior for ANY network app because sometimes servers are down or unreachable for one reason or another.

You can work around this particular error by disabling certificate revocation checks, but I wouldn't recommend it in most cases.

client.CheckCertificateRevocation = false;

This was all explained in the FAQ, by the way, which was linked in the exception message.

How can I make the exception message clearer? I get asked this question at least once per week, sometimes daily.

Do people not read exception messages and just immediately jump to reporting "bugs"? Do they not notice the link to the FAQ?

I spent a lot of time working to make SslHandshakeException helpful instead of just letting Microsoft's SSL exceptions bubble up to users because those exceptions are extremely useless.

SslHandshakeException, on the other hand, gives you all the information you need on a silver platter.

Honestly it seems like no one reads exception messages to me and assumes all exceptions are bugs.

Why?

Thanks for your reply. I really have read the FAQ and even googled on the internent.

  1. I thinks this is not the problem of mail server
    because the same code is ok on windows and linux, and they all connect the same mail server

  2. I tried STARTTLS before, it just blocked, no error no response.

  3. network is ok.

This maybe not a bug, as I googled, no one report such problem on android. Maybe I should set some special param to adapt the mail server. But the same code is ok on other platform. Could the library handle the calling difference on different platform?

I thinks this is not the problem of mail server because the same code is ok on windows and linux, and they all connect the same mail server

I never said it was a problem with the mail server. It's a problem connecting to the ssl certificate authority server.

This is something that System.Security.dll's SslStream does in order to verify that the SSL certificate is authentic.

It has nothing to do with MailKit and it has nothing to do with your mail server.

Thank you for explaining the problem.
So maybe the root problem is System.Security.dll's SslStream is not very stable on android?

I doubt that's the problem. But go ahead and go to the dotnet project'a GitHub page and file a bug report.

ok, thanks