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

HTTPS proxy support #1251

Closed
MaheshBGajera opened this issue Sep 2, 2021 · 11 comments
Closed

HTTPS proxy support #1251

MaheshBGajera opened this issue Sep 2, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@MaheshBGajera
Copy link

MaheshBGajera commented Sep 2, 2021

I am using this library for one of my project where in I fetch emails using IMAP client and I use proxy there.
I use HttpProxyClient and it seems to be working fine but now I realise that I need my proxy to work on HTTPS not HTTP for some security reasons(my proxy credentials are not encrypted over wire).

Is there any possibility that you can support HTTPS proxy here?

OR does Socks5ProxyClient supports TLS?

Thanks

@jstedfast jstedfast added the enhancement New feature or request label Sep 2, 2021
@jstedfast
Copy link
Owner

I will put this on the radar for 3.0.

The problem with trying to add this to 2.x is that the proxy needs to return a Socket rather than a Stream.

I will need to modify it to return a Stream for this to be possible.

@MaheshBGajera
Copy link
Author

Thank a lot. Do you have any expected release date for 3.0?

@jstedfast
Copy link
Owner

I do not have an expected release date, but I've already been working toward a 3.0 release in my vnext branch.

@jstedfast
Copy link
Owner

I've created a GitHub Project board. Assuming you can at least view it, it should give you an idea of the progress I'm making toward v3.0.

There's also a MimeKit 3.0 board.

jstedfast added a commit that referenced this issue Sep 5, 2021
@jstedfast
Copy link
Owner

This is now implemented in the vnext branch

@MaheshBGajera
Copy link
Author

thank you.

@jstedfast
Copy link
Owner

If you can, please test to make sure it works.

jstedfast added a commit that referenced this issue Sep 10, 2021
@jstedfast
Copy link
Owner

Have you tested this at all?

I'd like to make a 3.0 release but I need this tested first.

@MaheshBGajera
Copy link
Author

I tested https proxy on nuget 3.0.0-preview1 and I am getting following exception.

MailKit.Security.SslHandshakeException: An error occurred while attempting to establish an SSL or TLS connection.

The host name did not match the name given in the server's SSL certificate.

---> System.Security.Authentication.AuthenticationException: The remote certificate was rejected by the provided RemoteCertificateValidationCallback.
at System.Net.Security.SslStream.SendAuthResetSignal(ProtocolToken message, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](TIOAdapter adapter, Boolean receiveFirst, Byte[] reAuthenticationData, Boolean isApm)
at MailKit.Net.Proxy.HttpsProxyClient.ConnectAsync(String host, Int32 port, Boolean doAsync, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MailKit.Net.Proxy.HttpsProxyClient.ConnectAsync(String host, Int32 port, Boolean doAsync, CancellationToken cancellationToken)
at MailKit.Net.Proxy.ProxyClient.ConnectAsync(String host, Int32 port, Int32 timeout, CancellationToken cancellationToken)
at MailKit.MailService.ConnectNetwork(String host, Int32 port, Boolean doAsync, CancellationToken cancellationToken)

@jstedfast
Copy link
Owner

@MaheshBGajera you will need to override the ServerCertificateValidationCallback property on the HttpsProxyClient to manually validate the SSL certificate.

As the error suggests, the hostname in the SSL certificate does not match the hostname of the proxy that you are connecting to.

@jstedfast
Copy link
Owner

MailKit v3.0.0 has been released with this feature.

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

No branches or pull requests

2 participants