signxml icon indicating copy to clipboard operation
signxml copied to clipboard

How to add <X509SubjectName> tag in <X509Data> in KeyInfo?

Open rohts-patil opened this issue 3 years ago • 2 comments

As of now, when I use sign method, I get the xml output as

<ds:KeyInfo>
   <ds:X509Data>
	<ds:X509Certificate></ds:X509Certificate>
   </ds:X509Data>
</ds:KeyInfo>

I want output as

<ds:KeyInfo>
   <ds:X509Data>
        <ds:X509SubjectName></ds:X509SubjectName>
	<ds:X509Certificate></ds:X509Certificate>
   </ds:X509Data>
</ds:KeyInfo>

Is this possible in the current version of library?

rohts-patil avatar Sep 08 '21 20:09 rohts-patil

Yes, I have done this. You can you use parameter key_info and pass in a etree.Element.

The way to create this element is simple, you need to create an element with a namespace. Then add SubElement to this element and then finally pass it as value to the argument.

Eg:

I'll link you to a stackoverflow answer where you can learn how to create element with a namespace.

Link

signed_root.key(cert=cert, key=key, key_info=custom)

rahul-s-bhatt avatar Oct 19 '21 05:10 rahul-s-bhatt

I need to do this, any of you can share some example? @rahul-s-bhatt @rohts-patil

vitorvendrami avatar Jul 06 '22 22:07 vitorvendrami