Python + BH City Hall

Asked

Viewed 494 times

3

I am trying to integrate my Python system with PBH in the question of Nfse. The layout of the file is correct, however, I cannot sign the XML.

The layout and this one :

    <Signature Id="Ass_rps:ABCDZ">
        <SignedInfo>
            <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/>
            <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
            <Reference URI="#rps:1ABCDZ">
               <Transforms>
                  <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                 </Transforms>
                 <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                 <DigestValue> </DigestValue>
           </Reference>
           </SignedInfo>
                 <SignatureValue> </SignatureValue>
            <KeyInfo>
                 <X509Data>
                   <X509Certificate> </X509Certificate>
                 </X509Data>
             </KeyInfo>
      </Signature>

Before this part in the note comes the tags with values, service description, etc. I am in great need of help to generate Digestvalue, Signaturevalue and X509certificate in python. Someone can help me?

Thank you very much,

  • 1

    Do you have a link to a reference, a documentation, something like that? In general, the DigestValue is the SHA1 of something, the X509Certificate is a certificate in standard format using the RSA (think) algorithm, and the SignatureValue is the signature of DigestValue using the certificate and the RSA-SHA1 algorithm. This is a very standardized method, if you look right here in Sopt you will find similar questions for other languages. But to adapt this to Python, some extra details are needed, hence the importance of a link to documentation.

  • 1
  • Unfortunately not. I have examples of codes that are for NFE and are not so well documented as : https://github.com/aricaldeira/PySPED/tree/master/pysped If I could only remove the single part of the signature, I would. I’ve already emailed the author, but he hasn’t responded...

  • So the first step is to find the documentation - this kind of thing you can’t do on the "achometer".

  • The xml layout documentation is in http://www.pbh.gov.br/bhissdigital/download/nfse/Manual_De_Integracao_WebService_NFS-e_Belo_Horizonte.pdf, but it doesn’t say much.

No answers

Browser other questions tagged

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