Issue After Restoring PostgreSQL Backup - Key Not Found in Key Ring

Hello,

I’m running Bitwarden Unified and recently made a mistake that caused Bitwarden to stop working. I accidentally deleted the database volume and bitwarden volume.

Luckily, I had a PostgreSQL backup, but after restoring it, users are unable to log in anymore. The following error is showing up in the logs:

fail: Microsoft.EntityFrameworkCore.Query[10100]
      => SpanId:c1df7501c5b469ac, TraceId:ba703dfe7a6b851e7f64e3bd981cbc0a, ParentId:0000000000000000 => ConnectionId:0HN6LF5I0NLCA => RequestPath:/devices/knowndevice RequestId:0HN6LF5I0NLCA:00000001 => Bit.Api.Controllers.DevicesController.GetByIdentifierQuery (Api)
      An exception occurred while iterating over the results of a query for context type 'Bit.Infrastructure.EntityFramework.Repositories.DatabaseContext'.
      System.Security.Cryptography.CryptographicException: The key {e0f276a5-f37b-41b7-8b71-3ccec6d865bf} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
         at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
         at Bit.Infrastructure.EntityFramework.Converters.DataProtectionConverter.Unprotect(IDataProtector dataProtector, String value) in /source/src/Infrastructure.EntityFramework/Converters/DataProtectionConverter.cs:line 30
         at lambda_method65(Closure, QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator)
         at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
      System.Security.Cryptography.CryptographicException: The key {e0f276a5-f37b-41b7-8b71-3ccec6d865bf} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
         at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
         at Bit.Infrastructure.EntityFramework.Converters.DataProtectionConverter.Unprotect(IDataProtector dataProtector, String value) in /source/src/Infrastructure.EntityFramework/Converters/DataProtectionConverter.cs:line 30
         at lambda_method65(Closure, QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator)
         at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
fail: Bit.Api.Utilities.ExceptionHandlerFilterAttribute[0]
      => SpanId:c1df7501c5b469ac, TraceId:ba703dfe7a6b851e7f64e3bd981cbc0a, ParentId:0000000000000000 => ConnectionId:0HN6LF5I0NLCA => RequestPath:/devices/knowndevice RequestId:0HN6LF5I0NLCA:00000001 => Bit.Api.Controllers.DevicesController.GetByIdentifierQuery (Api)
      The key {e0f276a5-f37b-41b7-8b71-3ccec6d865bf} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
      System.Security.Cryptography.CryptographicException: The key {e0f276a5-f37b-41b7-8b71-3ccec6d865bf} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
         at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
         at Bit.Infrastructure.EntityFramework.Converters.DataProtectionConverter.Unprotect(IDataProtector dataProtector, String value) in /source/src/Infrastructure.EntityFramework/Converters/DataProtectionConverter.cs:line 30
         at lambda_method65(Closure, QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator)
         at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()
         at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
         at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleOrDefaultAsync[TSource](IAsyncEnumerable`1 asyncEnumerable, CancellationToken cancellationToken)
         at Bit.Infrastructure.EntityFramework.Repositories.UserRepository.GetByEmailAsync(String email) in /source/src/Infrastructure.EntityFramework/Repositories/UserRepository.cs:line 24
         at Bit.Api.Controllers.DevicesController.GetByIdentifier(String email, String identifier) in /source/src/Api/Controllers/DevicesController.cs:line 229
         at Bit.Api.Controllers.DevicesController.GetByIdentifierQuery(String Email, String DeviceIdentifier) in /source/src/Api/Controllers/DevicesController.cs:line 217
         at lambda_method12(Closure, Object)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
         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>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

Has anyone experienced something similar or have any advice on how to fix this issue? Any help would be greatly appreciated!

Thanks in advance.
Oliver

Hi Duke! Sorry you’re going through some pain with the restore. Have you contacted Support (Get in Touch | Bitwarden) on this issue, yet?

Hi eck,

I’ve already reached out to support regarding this issue, but unfortunately, they were unable to assist. It turns out that I did not back up the directory containing the necessary key, which means my database backup is essentially useless.

Fortunately, I was still able to export my passwords from the browser add-on, so I didn’t lose everything after all. It’s not a complete solution, but at least I managed to save the most important part.

Oliver

Ah, sorry @Duke. Glad you were able to still recover, though!

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.