Thank you for the link. From a first inspection the code seems similar, but I’ll do a deep dive to try and implement the snippet relevant code instead of the one we have.
Regarding your questions:
- The KMS provider remains the same in the key vault.
"masterKey" : {
"provider" : "gcp",
"projectId" : "project-example",
"location" : "location-test",
"keyRing" : "example-location-keyring",
"keyName" : "gke-master-key-test"
}
For the full stacktrace:
---> MongoDB.Driver.Encryption.MongoEncryptionException: Encryption related exception: HMAC validation failure.
---> MongoDB.Libmongocrypt.CryptException: HMAC validation failure
at MongoDB.Libmongocrypt.Status.ThrowExceptionIfNeeded()
at MongoDB.Libmongocrypt.CryptContext.FinalizeForEncryption()
at MongoDB.Driver.Encryption.LibMongoCryptControllerBase.ProcessStates(CryptContext context, String databaseName, CancellationToken cancellationToken)
at MongoDB.Driver.Encryption.ExplicitEncryptionLibMongoCryptController.DecryptField(BsonBinaryData encryptedValue, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MongoDB.Driver.Encryption.ExplicitEncryptionLibMongoCryptController.DecryptField(BsonBinaryData encryptedValue, CancellationToken cancellationToken)
at PTest.Shared.Database.Mongo.Files.MongoEncryptedFileRepository`1.DecryptStream(ClientEncryption clientEncryption, Stream encryptedStream, CancellationToken cancellationToken) in /home/vsts/work/1/s/shared/dotnet/Database.Mongo/Files/MongoEncryptedFileRepository.cs:line 84
at PTest.Shared.Database.Mongo.Files.MongoEncryptedFileRepository`1.ReadFileAsync(String fileId, CancellationToken cancellationToken) in /home/vsts/work/1/s/shared/dotnet/Database.Mongo/Files/MongoEncryptedFileRepository.cs:line 43
at PTest.Shared.Database.Mongo.Files.MongoEncryptedFileRepository`1.ReadFileAsync(String fileId, CancellationToken cancellationToken) in /home/vsts/work/1/s/shared/dotnet/Database.Mongo/Files/MongoEncryptedFileRepository.cs:line 43
at PTest.Services.Impl.PartIndexing.PartIndexingService.GetPTImageAsync(GetPTImage request, CancellationToken cancellationToken) in /home/vsts/work/1/s/PTest-api/Services/PTest.Services.Impl/PTIndex/PTIndexService.cs:line 478
--- End of inner exception stack trace ---
at PTest.Services.Impl.PartIndexing.PartIndexingService.GetPTImageAsync(GetPTImage request, CancellationToken cancellationToken) in /home/vsts/work/1/s/PTest-api/Services/PTest.Services.Impl/PartIndexing/PartIndexingService.cs:line 487
at PTest.BackendApi.WebApi.Controllers.Public.FilesController.PTImageAsync(Guid pId) in /home/vsts/work/1/s/PTest-api/WebApi/Controllers/Public/FilesController.cs:line 379
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at PTest.BackendApi.WebApi.GlobalExceptionHandler.Invoke(HttpContext context) in /home/vsts/work/1/s/PTest-api/WebApi/GlobalExceptionHandler.cs:line 55