xml error eSocial: Invalid event signature. Only one 'Keyinfo/X509data' Element is required/allowed

Asked

Viewed 1,165 times

1

I have the error: Invalid event signature. Only one 'Keyinfo/X509data' Element is required/allowed

Before that I received the error that should change the signature method Transform to:

<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315">

Before was:

<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />

link used as the basis for signing xml: https://blogs.msdn.microsoft.com/winsdk/2015/11/14/using-sha256-with-the-signedxml-class/

Note: After using the method to sign, I noticed that you do not create this part:

<KeyInfo>
  <X509Data> 
    <X509Certificate>...</X509Certificate>         
  </X509Data> 
</KeyInfo>

Can that be it? If yes what might be missing to create that part in XML?

  • I had the same problem, but in PHP, I will leave my solution on record if someone has the same difficulty. The error was in converting the pfx certificate. Converting the pfx certificate to pem must be via the following openssl command: openssl pkcs12 -in /var/cert.pfx -out var/cert.pem -nodes

1 answer

0

I was able to identify the problem. If someone goes through the same problem follows the solution

Code needed to be included:

Dim KeyInfo As KeyInfo = New KeyInfo()
Dim keyInfoData As KeyInfoX509Data = New KeyInfoX509Data(cert)
KeyInfo.AddClause(keyInfoData)
SignedXml.KeyInfo = KeyInfo

To add the certificate information below the signature

Browser other questions tagged

You are not signed in. Login or sign up in order to post.