.NET 9.0 下的 AsposePDF 加密错误

问题描述 投票:0回答:1

尝试加密 AsposePDF.Document(版本 21.12.0)时,进行以下测试:

using Aspose.Pdf;
using Aspose.Pdf.Facades;
using System.Threading.Tasks;
using Xunit;

namespace qbo4.Document.AsposePDF.Tests
{
    public class Sample
    {
        /// <summary>
        /// Proof of concept for .net9.0 bug
        /// </summary>
        [Fact]
        public async Task Encrypt()
        {
            using var stream = System.IO.File.OpenRead("Samples\\LoremIpsum.pdf");
            var document = new Aspose.Pdf.Document(stream, true);
            document.Encrypt("UserPwd", "OwnerPwd", DocumentPrivilege.AllowAll, CryptoAlgorithm.AESx256, false);
        }
    }
}

在 .NET 8.0 中成功,但在 .NET 9.0 中失败,并显示以下消息:

Message: 
#=zG5rLZShdh3CELHyHFONFsmrfaE_HOBi$4cDy6i8= : Permissions check failed (invalid Perms value).

Stack Trace:    
#=zeTEHGseWl$E2b74zvJPs0HHe2GrvBVcqxoAIPjc=.#=znlBKJSgVZQ$X(Byte[] #=zoJc0bBFZx5L_, Byte[] #=z5PP7WSAN_Puf)
#=zeTEHGseWl$E2b74zvJPs0HHe2GrvBVcqxoAIPjc=.#=zbKiLPP9rrbwe(Byte[] #=z5yMKBFc=, Byte[] #=zsCj_mHU=, Byte[] #=zJRqMY5E=, Byte[] #=zax0MxxE=, Byte[] #=zhUOtHjw=, Byte[] #=zb2D18pKtXA6C)
#=zeTEHGseWl$E2b74zvJPs0HHe2GrvBVcqxoAIPjc=.#=zbKiLPP9rrbwe(String #=z5yMKBFc=)
#=zeTEHGseWl$E2b74zvJPs0HHe2GrvBVcqxoAIPjc=.#=zpNY3WNU=()
#=zN0AKskZRa4sFhJb929qOWL0wOw2ARAWaIurPKls=.#=z3T6JzbY=(#=zcyQeqqe7an_SpTkOfNvmJP1IH0O2I6qiCW3EGhc= #=zfa0GOts=)
#=zCBpuUhOf9gLm4eLHWOipVbPjidD4p1BOQ_PAXYg=.ctor(#=zTFxHU34pwOp5ybVTSXLvyvVL$UUeaQ6YBTADGfoxdNCl #=zufuHgWxtWLBjto91QQ==, Byte[] #=zhwE5S8o=, Int32 #=zyvQDV$M=, String #=z5yMKBFc=)
#=zCBpuUhOf9gLm4eLHWOipVbPjidD4p1BOQ_PAXYg=.#=z2Uv03sc=(#=zTFxHU34pwOp5ybVTSXLvyvVL$UUeaQ6YBTADGfoxdNCl #=zufuHgWxtWLBjto91QQ==, Byte[] #=zhwE5S8o=, String #=z5yMKBFc=)
#=zCCSibLhnfKyR126MVnj5KOhtFSVe.#=zSKm_Mog=()
#=zCCSibLhnfKyR126MVnj5KOhtFSVe.#=zSpWwIfXjF_Bn(Boolean #=z7$j9AfM=)
#=z8bUdn7NB3HniUI$5rsmHmMh_8aU3.#=z_xK8kX8=(String #=zPA9blhSdh5oV, String #=zhNDd5pPctgqq, #=zjigdnpEe8jlppxNHW9WluVV6iGSI #=zyvQDV$M=, CryptoAlgorithm #=ztHPzHXvDFDl_, Boolean #=zwi6ylDV5lUBE)
Document.Encrypt(String userPassword, String ownerPassword, Permissions permissions, CryptoAlgorithm cryptoAlgorithm, Boolean usePdf20)
Document.Encrypt(String userPassword, String ownerPassword, DocumentPrivilege privileges, CryptoAlgorithm cryptoAlgorithm, Boolean usePdf20)
Sample.Encrypt() line 18

有什么建议的解决方法吗?

aspose.pdf .net-9.0
1个回答
0
投票

此问题已通过升级到 Aspose 版本 24.12.0 得到解决。

@Hoodlum,我认为这不是您正在处理的问题,但我选择通过直接引用来解决 Aspose v 24.12.0 中对

System.Security.Cryptography.Pkcs 8.0
的安全漏洞引用:

<PackageReference Include="System.Security.Cryptography.Pkcs" Version="9.*" />

此覆盖通过了我们的测试套件,包括密码保护的使用(在 Aspose 21.12.0 下不起作用)。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.