@@ -20,7 +20,6 @@ public class CoreHttpClientConfiguration : ICoreHttpClientConfiguration
2020 /// </summary>
2121 private CoreHttpClientConfiguration (
2222 TimeSpan timeout ,
23- bool skipSslCertVerification ,
2423 int numberOfRetries ,
2524 int backoffFactor ,
2625 double retryInterval ,
@@ -31,7 +30,6 @@ private CoreHttpClientConfiguration(
3130 bool overrideHttpClientConfiguration )
3231 {
3332 Timeout = timeout ;
34- SkipSslCertVerification = skipSslCertVerification ;
3533 NumberOfRetries = numberOfRetries ;
3634 BackoffFactor = backoffFactor ;
3735 RetryInterval = retryInterval ;
@@ -47,11 +45,6 @@ private CoreHttpClientConfiguration(
4745 /// </summary>
4846 public TimeSpan Timeout { get ; }
4947
50- /// <summary>
51- /// Gets Whether to skip verification of SSL certificates.
52- /// </summary>
53- public bool SkipSslCertVerification { get ; }
54-
5548 /// <summary>
5649 /// Gets Number of times the request is retried.
5750 /// </summary>
@@ -97,7 +90,6 @@ public override string ToString()
9790 {
9891 return "HttpClientConfiguration: " +
9992 $ "{ Timeout } , " +
100- $ "{ SkipSslCertVerification } , " +
10193 $ "{ NumberOfRetries } , " +
10294 $ "{ BackoffFactor } , " +
10395 $ "{ RetryInterval } , " +
@@ -116,7 +108,6 @@ public Builder ToBuilder()
116108 {
117109 var builder = new Builder ( )
118110 . Timeout ( Timeout )
119- . SkipSslCertVerification ( SkipSslCertVerification )
120111 . NumberOfRetries ( NumberOfRetries )
121112 . BackoffFactor ( BackoffFactor )
122113 . RetryInterval ( RetryInterval )
@@ -134,7 +125,6 @@ public Builder ToBuilder()
134125 public class Builder
135126 {
136127 private TimeSpan timeout = TimeSpan . FromSeconds ( 100 ) ;
137- private bool skipSslCertVerification = false ;
138128 private int numberOfRetries = 0 ;
139129 private int backoffFactor = 2 ;
140130 private double retryInterval = 1 ;
@@ -147,7 +137,7 @@ public class Builder
147137 {
148138 "GET" , "PUT"
149139 } . Select ( val => new HttpMethod ( val ) ) . ToImmutableList ( ) ;
150- private HttpClient httpClientInstance = null ;
140+ private HttpClient httpClientInstance = new HttpClient ( ) ;
151141 private bool overrideHttpClientConfiguration = true ;
152142
153143 /// <summary>
@@ -161,17 +151,6 @@ public Builder Timeout(TimeSpan timeout)
161151 return this ;
162152 }
163153
164- /// <summary>
165- /// Sets the SkipSslCertVerification.
166- /// </summary>
167- /// <param name="skipSslCertVerification">Bool for skipping (or not) SSL certificate verification</param>
168- /// <returns>Builder.</returns>
169- public Builder SkipSslCertVerification ( bool skipSslCertVerification )
170- {
171- this . skipSslCertVerification = skipSslCertVerification ;
172- return this ;
173- }
174-
175154 /// <summary>
176155 /// Sets the NumberOfRetries.
177156 /// </summary>
@@ -246,7 +225,7 @@ public Builder RequestMethodsToRetry(IList<HttpMethod> requestMethodsToRetry)
246225 /// <returns>Builder.</returns>
247226 public Builder HttpClientInstance ( HttpClient httpClientInstance , bool overrideHttpClientConfiguration = true )
248227 {
249- this . httpClientInstance = httpClientInstance ;
228+ this . httpClientInstance = httpClientInstance ?? new HttpClient ( ) ;
250229 this . overrideHttpClientConfiguration = overrideHttpClientConfiguration ;
251230 return this ;
252231 }
@@ -259,41 +238,15 @@ public CoreHttpClientConfiguration Build()
259238 {
260239 return new CoreHttpClientConfiguration (
261240 timeout ,
262- skipSslCertVerification ,
263241 numberOfRetries ,
264242 backoffFactor ,
265243 retryInterval ,
266244 maximumRetryWaitTime ,
267245 statusCodesToRetry ,
268246 requestMethodsToRetry ,
269- GetInitializedHttpClientInstance ( ) ,
247+ httpClientInstance ,
270248 overrideHttpClientConfiguration ) ;
271249 }
272-
273- private HttpClient GetInitializedHttpClientInstance ( )
274- {
275- if ( overrideHttpClientConfiguration )
276- {
277- if ( skipSslCertVerification )
278- {
279- var httpClientHandler = new HttpClientHandler
280- {
281- ServerCertificateCustomValidationCallback = ( message , cert , chain , errors ) => { return true ; }
282- } ;
283- return new HttpClient ( httpClientHandler , disposeHandler : true )
284- {
285- Timeout = timeout ,
286- } ;
287- }
288-
289- var httpClient = httpClientInstance ?? new HttpClient ( ) ;
290- httpClient . Timeout = timeout ;
291-
292- return httpClient ;
293- }
294-
295- return httpClientInstance ?? new HttpClient ( ) ;
296- }
297250 }
298251 }
299252}
0 commit comments