Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ProtectKeysWithDpapiNG with SID用于GMSA用户引发异常_C#_Dpapi_Gmsa - Fatal编程技术网

C# ProtectKeysWithDpapiNG with SID用于GMSA用户引发异常

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

您好,我们正在尝试使用DPAPI-NG编写一个.net core控制台应用程序,该应用程序将提示运行它的用户传入base64string密钥,然后该密钥将存储在设置文件中,供作为GMSA运行的应用程序用于加密。我试图设置Dapi NG,但它抛出异常,似乎无法通过

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
的数据类型和值?