https://bugs.documentfoundation.org/show_bug.cgi?id=173091
Bug ID: 173091
Summary: Windows: XAdES signing of ODF documents fails and
disposes the calling URP bridge
Product: LibreOffice
Version: 26.2.5.2 release
Hardware: x86-64 (AMD64)
OS: Windows (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: LibreOffice
Assignee: [email protected]
Reporter: [email protected]
Description:
Description
===========
On LibreOffice 26.2.5.2 under Windows, I am unable to digitally sign ODF
documents (XAdES).
The same certificate infrastructure works for digitally signing exported PDF
files (PAdES), but signing ODT documents fails.
The issue can be reproduced both from the LibreOffice graphical interface and
programmatically through the UNO DocumentDigitalSignatures service.
Manual behaviour
================
1. Create a new Writer document.
2. Enter a small amount of text.
3. Save it as ODT.
4. Go to File > Digital Signatures > Digital Signatures.
5. Select a personal signing certificate that LibreOffice detects.
6. Attempt to sign the document.
Actual result:
The certificate selection does not result in a signature being added. The
dialog returns without the document being signed.
No valid document signature is created.
This was tested with both ODF 1.3 Extended and ODF 1.4 documents.
Certificate used for the minimal reproduction
=============================================
To eliminate possible certificate naming or trust issues, a deliberately
minimal test certificate was created:
Subject: CN=JCMorani
Issuer: CN=JCMorani
RSA: 2048 bits
Signature algorithm: SHA-256 / RSA
Key usage: Digital Signature
Basic Constraints: end entity (CA=false)
Certificate provider: Microsoft Enhanced RSA and AES Cryptographic Provider
SHA-1:
B92FE501240635D62B8B94AF80E89154A76A8E87
The certificate is stored in CurrentUser\My, with its public certificate also
trusted through CurrentUser\TrustedPeople.
LibreOffice itself reports immediately before the signing attempt:
getCertificateCharacters() = 5
HAS_PRIVATE_KEY = True
SELF_SIGNED = True
verifyCertificate() = 0 (VALID)
getCertificateUsage() = DIGITAL_SIGNATURE
Windows certutil also successfully tests the private key.
Therefore, LibreOffice detects:
- the certificate;
- the associated private key;
- the Digital Signature key usage;
- and considers the certificate valid.
UNO reproduction
================
A fresh Writer document containing only:
TEST
was created using an isolated temporary LibreOffice profile.
The DocumentDigitalSignatures service was explicitly instantiated using the
document's actual ODF version.
For ODF 1.3 Extended:
DocumentDigitalSignatures.createWithVersion("1.3")
The resulting ODT was verified before signing:
office:version = "1.3"
manifest:version = "1.3"
META-INF/documentsignatures.xml did not exist before signing.
Immediately before the signature call:
getCertificateCharacters() = 5
HAS_PRIVATE_KEY = True
verifyCertificate() = 0
The following call was then made:
signDocumentWithCertificate(certificate, storage, signatureStream)
Actual result:
No boolean value is returned.
Instead, the caller receives:
com.sun.star.lang.DisposedException:
Binary URP bridge disposed during call
After this exception:
- soffice.bin remains running;
- soffice.bin remains responsive;
- the UNO port remains listening;
- a new UNO connection to the same LibreOffice process succeeds;
- only the calling URP bridge is disposed;
- META-INF/documentsignatures.xml is NOT created;
- after reopening the ODT, verifyDocumentContentSignatures() returns 0 results;
- the document is considered NOT SIGNED.
ODF 1.4
=======
The exact same test was performed with:
DocumentDigitalSignatures.createWithVersion("1.4")
and a real ODF 1.4 document.
The result is identical:
com.sun.star.lang.DisposedException:
Binary URP bridge disposed during call
No META-INF/documentsignatures.xml is created and the document remains
unsigned.
Additional observations
=======================
The issue was also reproduced previously with another RSA signing certificate.
A certificate issued by a locally trusted test CA was also tested, without
solving the problem.
The minimal CN=JCMorani certificate was then created specifically to eliminate
possible problems related to spaces, accented characters, hyphens, certificate
chain construction, missing private key, or certificate trust.
LibreOffice reports this minimal certificate as VALID and explicitly detects
its private key, but ODF/XAdES signing still fails.
PDF/PAdES signing with LibreOffice works on the same Windows installation.
Expected result
===============
signDocumentWithCertificate() should create a valid XAdES document signature
and return normally.
META-INF/documentsignatures.xml should be created in the ODT package.
The graphical File > Digital Signatures workflow should also add the selected
certificate as a valid document signature.
Actual result
=============
ODF/XAdES signing does not complete.
>From UNO, signDocumentWithCertificate() disposes the calling Binary URP bridge
before returning a value.
No documentsignatures.xml is created and the ODT remains unsigned.
Environment
===========
LibreOffice: 26.2.5.2
Operating system: Windows 11 64-bit
Security environment reported by LibreOffice: Microsoft Crypto API
Certificate provider: Microsoft Enhanced RSA and AES Cryptographic Provider
Reproduced with:
- ODF 1.3 Extended
- ODF 1.4
PDF/PAdES signing works.
ODF/XAdES signing fails.
Steps to Reproduce:
1. On Windows 11 64-bit, open LibreOffice Writer 26.2.5.2.
2. Create a new Writer document containing only:
TEST
3. Save the document as an ODT file.
4. Go to:
File > Digital Signatures > Digital Signatures
5. Click "Sign Document".
6. Select the personal certificate "CN=JCMorani".
The certificate is detected by LibreOffice and has the following properties:
- RSA 2048 bits
- SHA-256
- Key Usage: Digital Signature
- private key available
- LibreOffice getCertificateCharacters() = 5
- HAS_PRIVATE_KEY = True
- LibreOffice verifyCertificate() = 0 (VALID)
The certificate is stored in CurrentUser\My and its public certificate is
trusted through CurrentUser\TrustedPeople.
7. Try to validate/sign the document.
The problem can also be reproduced programmatically with the UNO service
DocumentDigitalSignatures.
With a fresh ODF 1.3 Extended document:
DocumentDigitalSignatures.createWithVersion("1.3")
and with a fresh ODF 1.4 document:
DocumentDigitalSignatures.createWithVersion("1.4")
then calling:
signDocumentWithCertificate(certificate, storage, signatureStream)
produces the same failure.
Actual Results:
In the graphical interface, selecting the certificate does not add a digital
signature. The certificate selection dialog closes/returns, but the document
remains unsigned.
When reproducing the problem through UNO, signDocumentWithCertificate() does
not return a boolean value.
Instead, it raises:
com.sun.star.lang.DisposedException:
Binary URP bridge disposed during call
The LibreOffice process itself remains running and responsive. A new UNO
connection to the same soffice.bin process can be established.
However:
- META-INF/documentsignatures.xml is not created;
- verifyDocumentContentSignatures() returns 0 signatures after reopening the
document;
- the document remains unsigned.
The same behaviour occurs with both ODF 1.3 Extended and ODF 1.4.
Expected Results:
LibreOffice should use the selected certificate and its private key to create a
valid XAdES document signature.
The graphical Digital Signatures dialog should show the newly added signature.
When using the UNO API, signDocumentWithCertificate() should complete normally
and return its documented result.
META-INF/documentsignatures.xml should be created in the ODT package, and
verifyDocumentContentSignatures() should detect the resulting signature after
reopening the document.
Reproducible: Always
User Profile Reset: No
Additional Info:
LibreOffice version: 26.2.5.2
Operating system: Windows 11 64-bit
LibreOffice security environment: Microsoft Crypto API
Minimal certificate used for reproduction:
Subject: CN=JCMorani
Issuer: CN=JCMorani
SHA-1: B92FE501240635D62B8B94AF80E89154A76A8E87
RSA: 2048 bits
Key Usage: Digital Signature
Provider: Microsoft Enhanced RSA and AES Cryptographic Provider
LibreOffice reports:
getCertificateCharacters() = 5
HAS_PRIVATE_KEY = True
SELF_SIGNED = True
verifyCertificate() = 0 (VALID)
Windows certutil also successfully tests the private key.
The certificate name was deliberately reduced to "JCMorani" to exclude spaces,
hyphens, accented characters or other naming issues.
The issue was reproduced with:
- ODF 1.3 Extended
- ODF 1.4
The same LibreOffice installation can successfully digitally sign exported PDF
files using PAdES. The failure therefore appears specific to ODF/XAdES document
signing.
Programmatic reproduction through UNO consistently produces:
com.sun.star.lang.DisposedException: Binary URP bridge disposed during call
Only the calling URP bridge is disposed; soffice.bin remains alive and accepts
a new UNO connection.
--
You are receiving this mail because:
You are the assignee for the bug.