18
18
using System . Threading . Tasks ;
19
19
using System . Linq ;
20
20
using System ;
21
- using System . ComponentModel ;
21
+ using System . Net ;
22
22
using System . Threading ;
23
23
using System . Security . Cryptography . X509Certificates ;
24
24
@@ -31,7 +31,7 @@ public record DekId(string KekName, string Subject, int? Version, DekFormat? Dek
31
31
/// <summary>
32
32
/// A caching DEK Registry client.
33
33
/// </summary>
34
- public class CachedDekRegistryClient : IDekRegistryClient , IDisposable
34
+ public class CachedDekRegistryClient : IDekRegistryClient
35
35
{
36
36
private DekRestService restService ;
37
37
@@ -71,12 +71,16 @@ public int MaxCachedKeys
71
71
/// <param name="authenticationHeaderValueProvider">
72
72
/// The authentication header value provider
73
73
/// </param>
74
+ /// <param name="proxy">
75
+ /// The proxy server to use for connections
76
+ /// </param>
74
77
public CachedDekRegistryClient ( IEnumerable < KeyValuePair < string , string > > config ,
75
- IAuthenticationHeaderValueProvider authenticationHeaderValueProvider )
78
+ IAuthenticationHeaderValueProvider authenticationHeaderValueProvider ,
79
+ IWebProxy proxy = null )
76
80
{
77
81
if ( config == null )
78
82
{
79
- throw new ArgumentNullException ( "config properties must be specified. " ) ;
83
+ throw new ArgumentNullException ( "config" ) ;
80
84
}
81
85
var schemaRegistryUrisMaybe = config . FirstOrDefault ( prop =>
82
86
prop . Key . ToLower ( ) == SchemaRegistryConfig . PropertyNames . SchemaRegistryUrl ) ;
@@ -236,8 +240,9 @@ public CachedDekRegistryClient(IEnumerable<KeyValuePair<string, string>> config,
236
240
$ "Configured value for { SchemaRegistryConfig . PropertyNames . EnableSslCertificateVerification } must be a bool.") ;
237
241
}
238
242
239
- this . restService = new DekRestService ( schemaRegistryUris , timeoutMs , authenticationHeaderValueProvider ,
240
- SetSslConfig ( config ) , sslVerify ) ;
243
+ var sslCaLocation = config . FirstOrDefault ( prop => prop . Key . ToLower ( ) == SchemaRegistryConfig . PropertyNames . SslCaLocation ) . Value ;
244
+ var sslCaCertificate = string . IsNullOrEmpty ( sslCaLocation ) ? null : new X509Certificate2 ( sslCaLocation ) ;
245
+ this . restService = new DekRestService ( schemaRegistryUris , timeoutMs , authenticationHeaderValueProvider , SetSslConfig ( config ) , sslVerify , sslCaCertificate , proxy ) ;
241
246
}
242
247
243
248
/// <summary>
@@ -291,14 +296,6 @@ private List<X509Certificate2> SetSslConfig(IEnumerable<KeyValuePair<string, str
291
296
certificates . Add ( new X509Certificate2 ( certificateLocation , certificatePassword ) ) ;
292
297
}
293
298
294
- var caLocation =
295
- config . FirstOrDefault ( prop => prop . Key . ToLower ( ) == SchemaRegistryConfig . PropertyNames . SslCaLocation )
296
- . Value ?? "" ;
297
- if ( ! String . IsNullOrEmpty ( caLocation ) )
298
- {
299
- certificates . Add ( new X509Certificate2 ( caLocation ) ) ;
300
- }
301
-
302
299
return certificates ;
303
300
}
304
301
0 commit comments