Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5252

Make CreateHttpClientHandler() method virtual

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.14.0
    • netstd - Library
    • None
    • Patch Available

    Description

      The CreateHttpClientHandler() factory method of THttpTransport should be virtual instead of static. This allows overriding the method and manipulating the returned handler. Amongst others, one possible use case could be to relax the SSL/TLS validation checks intentionally for some custom purpose, like so:

      public class TCustomizedHttpTransport : THttpTransport
      {
      	public override HttpClientHandler CreateHttpClientHandler(X509Certificate[] certs = null)
      	{
      		var handler = base.CreateHttpClientHandler(certificates);
      		handler.ServerCertificateCustomValidationCallback = MyCallback;
      		return handler;
      	}
      
      	private bool MyCallback(object s, X509Certificate crt, X509Chain ch, SslPolicyErrors e)
      	{
      		var other_errors = e & (~SslPolicyErrors.RemoteCertificateNameMismatch);
      		return (SslPolicyErrors.None == other_errors);
      	}
      }
      

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            jensg Jens Geyer
            jensg Jens Geyer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m

                Slack

                  Issue deployment