Digital Signing Cert signing information missing

I had to add a digital signing procedure to macro enabled aspose cells workbooks within our app to meet a security requirement, and we recently had an issue with a user wherein their microsoft excel could not open and view the downloaded workbook that had said digital signature attached, due to the signature not being valid. After some digging, we saw that the signature itself seems to be missing the email and signing time information from the details.

cert-error.png (55.3 KB)

public static DigitalSignature GetDigitalSignature()
{
    const string comment = "Signing Digital Signature using Aspose.Cells";

    var app = AppDomain.CurrentDomain.BaseDirectory;
    var pfxPath = Path.GetFullPath(Path.Combine(app, @"<path>"));

    X509Certificate2 cert = new X509Certificate2(pfxPath);

    var digitalSignature =
        new DigitalSignature
            (cert, comment, DateTime.UtcNow);
    return digitalSignature;
}
var digitalSignature = GetDigitalSignature();

asposeWorkbook.VbaProject.Sign(digitalSignature);

I’ve included the code we used to sign the aspose workbooks as well.

Is there anything that we may be missing that would account for the issue described?

@JasonWard,

Could you please provide pfx file (with password details), input Excel file (if any), output Excel file and sample (runnable) code to evaluate your issue. You can zip these files and attach the zipped archive here, we will check it soon.

I can provide a current zip of a test project.
We did end up noticing that our certificate we had been trying to use was X509v3, which indicated to me that I needed to use X509Certificate instead of the X509Certificate2 object.
At that point, I realized that the DigitalSignature constructor was not able to consume that object, so I tried to run it as a byte[] instead.
Now, however, we are getting a new error, and I am wondering if the DigitalSignature functionality supports the X509Certificate class object at all.

Error:
image.png (44.0 KB)

Could not add the zip file, so here is the github link:
AsposeCells.DigitalSigning.Test

@JasonWard,

Thanks for the sample project with template and certificate files.

I did test your project with .NET6.0 as target framework in VS.NET, it works fine and I do not get any exception. Please note, for your line of code:

var devX509Certificate2 = new X509Certificate2(devWorkbookHcrcentralComPfxPath, string.Empty, X509KeyStorageFlags.MachineKeySet);

I got an exception “The specified network password is not correct” which means certificate password is incorrect, please provide valid password. However, when I used the lines instead, it works fine.

var friendlyX509Certificate2 = new X509Certificate2(friendlyCert2PfxPath, "mypassword", X509KeyStorageFlags.MachineKeySet);

            var vertBytes = friendlyX509Certificate2.GetRawCertData();

           var digitalSignature =
                new DigitalSignature
                    (friendlyX509Certificate2, comment, DateTime.UtcNow);
            return digitalSignature;

I got correct final (following) message with generated XSLM file.
“Is file properly signed: True”.