The platform display issue of adding digital signatures to Word documents using. pfx digital certificates

I have some questions that I would like to inquire about. I would greatly appreciate it if you could receive a timely response
Generate a PFX certificate using the. net built-in X509Certificates and make aspose. word the latest version 23.11.0. Add a digital signature to the Word document and use the certificate generated above to add a digital signature to Excel, which is also the latest version 23.11.0. The signature can be added normally. However, the Windows platform version displayed in the Word document signature is 6.1, while the Windows platform version displayed in the Excel document signature is 5.1
The core code is as follows

public static void generateCer()
{
    // 生成 RSA 密钥对
    using (var rsa = new RSACryptoServiceProvider(2048))
    {
        // 创建证书请求
        var certificateRequest = new CertificateRequest(
            "CN=myCer",
            rsa,
            HashAlgorithmName.SHA256,
            RSASignaturePadding.Pkcs1);

        // 创建证书
        var certificate = certificateRequest.CreateSelfSigned(DateTimeOffset.Now, DateTimeOffset.Now.AddYears(1));

        // 将证书及私钥保存为.pfx文件
        byte[] pfxBytes = certificate.Export(X509ContentType.Pfx, "Q123456");

        // 保存为文件
        System.IO.File.WriteAllBytes("myCer.pfx", pfxBytes);
    }
    //word
    //   文档目录的路径
    CertificateHolder certHolder = CertificateHolder.Create(certFilePath, passWd);


    SignOptions signOptions = new SignOptions
    {
        Comments = "Document was signed by Aspose",
        SignTime = DateTime.UtcNow,
    };
    DigitalSignatureUtil.Sign(sourceWordPath, outputWordPath, certHolder, signOptions);

    //excel
    var sourceDir = AppDomain.CurrentDomain.BaseDirectory;

    string certFileName = sourceDir + "123.pfx";
    string password = "ABCD123456";


    Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(sourceDir + "test.xlsx");

    Aspose.Cells.DigitalSignatures.DigitalSignatureCollection dsCollection = new Aspose.Cells.DigitalSignatures.DigitalSignatureCollection();

    X509Certificate2 certificate = new X509Certificate2(certFileName, password);

    Aspose.Cells.DigitalSignatures.DigitalSignature signature = new Aspose.Cells.DigitalSignatures.DigitalSignature(certificate, "Aspose.Cells added new digital signature in existing digitally signed workbook.", DateTime.UtcNow);
    dsCollection.Add(signature);

    workbook.AddDigitalSignature(dsCollection);

    workbook.Save(sourceDir + "outputDigitallySignedByCells.xlsx");
    workbook.Dispose();

resultImg

@ton777 WindowsVersion written into signature properties by Aspose.Words is hardcoded and is always 6.1. It is written into sig1.xml:

<WindowsVersion>6.1</WindowsVersion>

I suppose the value is also hardcoded in Aspose.Cells, unfortunately, I do not have access to Aspose.Cells code, so cannot tell for sure.

Thank you very much for your prompt response. Is there a better solution or solution for this situation? Thank you !!!

@ton777 As I have mentioned WindowsVersion is hardcoded and there is no way to change it when signing document using Aspose.Words, it is always 6.1.

Okay, thank you again sincerely for your attention and timely response to my question

1 Like