Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make more methods of MailServer protected / public #1880

Open
m-gallesio opened this issue Feb 3, 2025 · 1 comment
Open

Make more methods of MailServer protected / public #1880

m-gallesio opened this issue Feb 3, 2025 · 1 comment

Comments

@m-gallesio
Copy link

There is a dedicated way to make a SmtpClient use a custom certificate validation callback:
https://mimekit.net/docs/html/P_MailKit_MailService_ServerCertificateValidationCallback.htm

It is easy enough to implement a custom logic using the default as a model:

protected static bool DefaultServerCertificateValidationCallback (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)

However some components of the default function (IsUntrustedRoot and IsKnownMailServerCertificate) which would / could be repeated verbatim cannot be reused due to being private / internal.

Our current approach uses a custom subclass of SmtpClient and needs of the two the logic in IsUntrustedRoot, which is short enough to copy and adapt which however means replicating something that already exists in the library. We do not need IsKnownMailServerCertificate, and were us (or others) to need it it would be considerably more unwieldy to repeat.

I lack the experience to properly evaluate which of the many other components could be useful to subclasses, but I feel at least the two I noticed could be exposed.

@jstedfast
Copy link
Owner

To be honest, I've been planning to kill off IsKnownMailServerCertificate and if that goes away, there's no point in keeping IsUntrustedRoot.

Now that everyone is using dotnet (as opposed to mono) on Linux/Mac, it seems like these hacks aren't really needed anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants