Skip to content

Commit 55943a3

Browse files
authored
Improve missing KMS error message (confluentinc#6) (confluentinc#2279)
* Improve missing KMS error message Also enhance examples, some minor cleanup * Fix tests
1 parent e7ffcd8 commit 55943a3

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

examples/AvroGenericEncryption/Program.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static async Task Main(string[] args)
4848
AzureKmsDriver.Register();
4949
GcpKmsDriver.Register();
5050
HcVaultKmsDriver.Register();
51+
LocalKmsDriver.Register();
5152
FieldEncryptionExecutor.Register();
5253

5354
string bootstrapServers = args[0];
@@ -79,7 +80,10 @@ static async Task Main(string[] args)
7980
// optional Avro serializer properties:
8081
BufferBytes = 100
8182
};
82-
83+
// KMS properties can be passed as follows
84+
// avroSerializerConfig.Set("rules.secret.access.key", "xxx");
85+
// avroSerializerConfig.Set("rules.access.key.id", "xxx");
86+
8387
RuleSet ruleSet = new RuleSet(new List<Rule>(),
8488
new List<Rule>
8589
{

examples/AvroSpecificEncryption/Program.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static void Main(string[] args)
4545
AzureKmsDriver.Register();
4646
GcpKmsDriver.Register();
4747
HcVaultKmsDriver.Register();
48+
LocalKmsDriver.Register();
4849
FieldEncryptionExecutor.Register();
4950

5051
string bootstrapServers = args[0];
@@ -82,7 +83,10 @@ static void Main(string[] args)
8283
// optional Avro serializer properties:
8384
BufferBytes = 100
8485
};
85-
86+
// KMS properties can be passed as follows
87+
// avroSerializerConfig.Set("rules.secret.access.key", "xxx");
88+
// avroSerializerConfig.Set("rules.access.key.id", "xxx");
89+
8690
RuleSet ruleSet = new RuleSet(new List<Rule>(),
8791
new List<Rule>
8892
{

examples/JsonEncryption/Program.cs

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ static async Task Main(string[] args)
8282
AzureKmsDriver.Register();
8383
GcpKmsDriver.Register();
8484
HcVaultKmsDriver.Register();
85+
LocalKmsDriver.Register();
8586
FieldEncryptionExecutor.Register();
8687

8788
string bootstrapServers = args[0];
@@ -135,6 +136,9 @@ static async Task Main(string[] args)
135136
UseLatestVersion = true,
136137
BufferBytes = 100
137138
};
139+
// KMS properties can be passed as follows
140+
// jsonSerializerConfig.Set("rules.secret.access.key", "xxx");
141+
// jsonSerializerConfig.Set("rules.access.key.id", "xxx");
138142

139143
RuleSet ruleSet = new RuleSet(new List<Rule>(),
140144
new List<Rule>

examples/ProtobufEncryption/Program.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static async Task Main(string[] args)
5050
AzureKmsDriver.Register();
5151
GcpKmsDriver.Register();
5252
HcVaultKmsDriver.Register();
53+
LocalKmsDriver.Register();
5354
FieldEncryptionExecutor.Register();
5455

5556
string bootstrapServers = args[0];
@@ -96,7 +97,10 @@ message User {
9697
// optional Avro serializer properties:
9798
BufferBytes = 100
9899
};
99-
100+
// KMS properties can be passed as follows
101+
// protobufSerializerConfig.Set("rules.secret.access.key", "xxx");
102+
// protobufSerializerConfig.Set("rules.access.key.id", "xxx");
103+
100104
RuleSet ruleSet = new RuleSet(new List<Rule>(),
101105
new List<Rule>
102106
{

src/Confluent.SchemaRegistry.Encryption/KmsRegistry.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
// Refer to LICENSE for more information.
1616

17+
using System;
1718
using System.Collections.Generic;
1819
using System.Threading;
1920

@@ -61,7 +62,7 @@ public static IKmsDriver GetKmsDriver(string keyUrl)
6162
kmsDriversMutex.Release();
6263
}
6364

64-
return null;
65+
throw new ArgumentException("No KMS driver found for key URL: " + keyUrl); ;
6566
}
6667

6768
public static void RegisterKmsClient(IKmsClient kmsClient)

src/Confluent.SchemaRegistry/Rest/DataContracts/Schema.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,18 @@ public class Schema : IComparable<Schema>, IEquatable<Schema>
3030
#region API backwards-compatibility hack
3131

3232
/// <summary>
33-
/// DEPRECATED. The subject the schema is registered against.
33+
/// The subject the schema is registered against.
3434
/// </summary>
35-
[Obsolete("Included to maintain API backwards compatibility only. Use RegisteredSchema instead. This property will be removed in a future version of the library.")]
3635
public virtual string Subject { get; set; }
3736

3837
/// <summary>
39-
/// DEPRECATED. The schema version.
38+
/// The schema version.
4039
/// </summary>
41-
[Obsolete("Included to maintain API backwards compatibility only. Use RegisteredSchema instead. This property will be removed in a future version of the library.")]
4240
public virtual int Version { get; set; }
4341

4442
/// <summary>
45-
/// DEPRECATED. Unique identifier of the schema.
43+
/// Unique identifier of the schema.
4644
/// </summary>
47-
[Obsolete("Included to maintain API backwards compatibility only. Use RegisteredSchema instead. This property will be removed in a future version of the library.")]
4845
public virtual int Id { get; set; }
4946

5047
/// <summary>

0 commit comments

Comments
 (0)