Hi.
I’m using Couchbase with field level encryption and it works fine when using a default encryption key, but now I need to support different encryption keys for different fields.
I use to have my cluster configured with a default encryptor and that is why it was working fine:
var cryptoManager = DefaultCryptoManager.Builder()
.Decryptor(provider.Decryptor())
.DefaultEncryptor(provider.Encryptor("my-key")) // Default encryptor was being defined
.Build();
But now I’m adding many keys to the provider and then adding them to the cryptoManager:
var keys = GetEncryptionKeys();
var provider = new AeadAes256CbcHmacSha512Provider(new AeadAes256CbcHmacSha512Cipher(), new Keyring(keys));
var cryptoManagerBuilder = DefaultCryptoManager.Builder();
cryptoManagerBuilder.Decryptor(provider.Decryptor());
foreach (var k in keys)
{
// Adds the encryption keys one by one
// So I end up with a list of keys: "my-key1", "my-key2", "my-key3"
cryptoManagerBuilder.Encryptor(k.Id, provider.Encryptor(k.Id));
}
var cryptoManager = cryptoManagerBuilder.Build();
That code works fine, but when I try to write or read files, I get this error:
Missing encryptor for alias ‘’
I am correctly defining my encryption key on the model field
I would expect Couchbase to identify that I want to use “my-key” from the list of encryption keys that I provided, but I get that error instead.
It starts “working” once I add a default encryptor, but it always uses the default, ignoring what was specified in the EncryptedField.KeyName value.
I don’t want to use a default encryptor, to prevent incorrectly encrypting with a default and not with what I really need.
Question
Is there a way for not having to specify a default encryptor and just use what is defined on each model property?