From 442cc2e9cfe35caa592e2db13462a296dad89bd7 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 5 Jun 2025 15:35:32 +0200 Subject: [PATCH] Enable nullable --- src/Core/Entities/User.cs | 5 +++++ .../Models/Data/PublicKeyEncryptionKeyPairData.cs | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Core/Entities/User.cs b/src/Core/Entities/User.cs index ad201ac624..5fbee6c6f7 100644 --- a/src/Core/Entities/User.cs +++ b/src/Core/Entities/User.cs @@ -258,6 +258,11 @@ public class User : ITableObject, IStorableSubscriber, IRevisable, ITwoFac public PublicKeyEncryptionKeyPairData GetPublicKeyEncryptionKeyPair() { + if (string.IsNullOrWhiteSpace(PrivateKey) || string.IsNullOrWhiteSpace(PublicKey)) + { + throw new InvalidOperationException("User public key encryption key pair is not fully initialized."); + } + return new PublicKeyEncryptionKeyPairData { WrappedPrivateKey = PrivateKey, diff --git a/src/Core/KeyManagement/Models/Data/PublicKeyEncryptionKeyPairData.cs b/src/Core/KeyManagement/Models/Data/PublicKeyEncryptionKeyPairData.cs index 1f9757f1dd..741288f65b 100644 --- a/src/Core/KeyManagement/Models/Data/PublicKeyEncryptionKeyPairData.cs +++ b/src/Core/KeyManagement/Models/Data/PublicKeyEncryptionKeyPairData.cs @@ -1,9 +1,10 @@ namespace Bit.Core.KeyManagement.Models.Data; +#nullable enable + public class PublicKeyEncryptionKeyPairData { - public string WrappedPrivateKey { get; set; } - public string SignedPublicKey { get; set; } - [System.Obsolete("Use SignedPublicKey instead for new code, if it is not null.")] - public string PublicKey { get; set; } + public required string WrappedPrivateKey { get; set; } + public string? SignedPublicKey { get; set; } + public required string PublicKey { get; set; } }