C# ProtectKeysWithDpapiNG with SID用于GMSA用户引发异常
您好,我们正在尝试使用DPAPI-NG编写一个.net core控制台应用程序,该应用程序将提示运行它的用户传入base64string密钥,然后该密钥将存储在设置文件中,供作为GMSA运行的应用程序用于加密。我试图设置Dapi NG,但它抛出异常,似乎无法通过C# ProtectKeysWithDpapiNG with SID用于GMSA用户引发异常,c#,dpapi,gmsa,C#,Dpapi,Gmsa,您好,我们正在尝试使用DPAPI-NG编写一个.net core控制台应用程序,该应用程序将提示运行它的用户传入base64string密钥,然后该密钥将存储在设置文件中,供作为GMSA运行的应用程序用于加密。我试图设置Dapi NG,但它抛出异常,似乎无法通过 var serviceCollection = new ServiceCollection(); serviceCollection.AddDataProtection() .Persist
var serviceCollection = new ServiceCollection();
serviceCollection.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(directorylocation))
.ProtectKeysWithDpapiNG(@"SID="+sid, flags: DpapiNGProtectionDescriptorFlags.None)
.SetApplicationName(appName);
当我尝试使用IDataProtector保护方法时,出现以下异常:
未处理的异常:System.Security.Cryptography.CryptographyException:无法解密指定的数据。
在Microsoft.AspNetCore.Cryptography.unsafentiveMethods.ThroweExceptionForNcryptStatusImpl(Int32 ntstatus)上
在Microsoft.AspNetCore.DataProtection.Cng.dpapisecreserializerhelper.unprotectedwithdpapingcore(Byte*pbData,UInt32 cbData)
在Microsoft.AspNetCore.DataProtection.Cng.dpapisecreserializerhelper.unprotectedwithdpaping(字节[]protectedData)
在Microsoft.AspNetCore.DataProtection.XmlEncryption.dpapingxmldeprocryptor.Decrypt(XElement encryptedElement)上
在Microsoft.AspNetCore.DataProtection.XmlEncryption.XmlEncryptionExtensions.DecryptElement(XElement元素,IActivator激活器)
位于Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.IIInternalXMLKeyManager.DeserializeDescriptorFromKeyElement(XElement keyElement)
在System.Lazy`1.ViaFactory(LazyThreadSafetyMode模式)
我最近也有类似的问题。您能否提供
sid
和directorylocation
的数据类型和值?