Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypt wsaa #53

Merged
merged 13 commits into from
Jun 10, 2021
Merged

crypt wsaa #53

merged 13 commits into from
Jun 10, 2021

Conversation

reingart
Copy link
Member

@reingart reingart commented Jun 9, 2021

Summary

Bring back cryptography branch from GSoC 2019 #25 of @NicolasSandoval
Changes from the original PR and after merge against main branch:

  • Removal of M2Crypto legacy library
  • SignTRA (CMS) and other certificate/private key
  • Proper dependencies were updated both for python2 and python3 (new)
  • 2 unit tests were added for sanity (new)
  • GitHub action updated to download crt/key testing credentials (new)

Checklist

  • Classes, Variables, function and methods logic ok
  • Comments written explaining what the code does
  • All python code is PEP8 compliant (run black .)
  • No lint issues (run flake8)
  • Test coverage with pytest implemented
  • Reviewers assigned (at least 1 mentor)

Manual test evidence

See UTs

$ python -m pyafipws.wsaa --debug --trace

Encodign in UTF-8
Usando CRT=reingart.crt KEY=reingart.key URL=https://wsaahomo.afip.gov.ar/ws/services/LoginCms SERVICE=wsfe TTL=36000
WSAA Version 3.11c  False
Creando TRA...
Firmando TRA...
Conectando a WSAA...
Llamando WSAA...
--------------------------------------------------------------------------------
POST https://wsaahomo.afip.gov.ar/ws/services/LoginCms
Content-type: text/xml; charset="UTF-8"
Content-length: 2722
SOAPAction: "None"

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="https://wsaahomo.afip.gov.ar/ws/services/LoginCms">
<soapenv:Header/>
<soapenv:Body>
    <ser:loginCms>
    <in0>MIIG+wYJKo...
xt71uptvMNqMGydoECL7

</in0></ser:loginCms>
</soapenv:Body>
</soapenv:Envelope>

date: Wed, 09 Jun 2021 04:13:37 GMT
content-type: text/xml;charset=utf-8
set-cookie: TS01b14f84=0145b27a9751dfe5164a62bb1b25a15f750c7a7f763428b3fd57a8677b6c07e0bdf60cfb3b; Path=/
transfer-encoding: chunked
status: 200
b'<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><loginCmsResponse xmlns="https://wsaahomo.afip.gov.ar/ws/services/LoginCms"><loginCmsReturn>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;\n&lt;loginTicketResponse version=&quot;1.0&quot;&gt;\n    &lt;header&gt;\n        &lt;source&gt;CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239&lt;/source&gt;\n        &lt;destination&gt;SERIALNUMBER=CUIT 20267565393, CN=reingart2019pub&lt;/destination&gt;\n        &lt;uniqueId&gt;1103203105&lt;/uniqueId&gt;\n        &lt;generationTime&gt;2021-06-09T01:13:37.152-03:00&lt;/generationTime&gt;\n        &lt;expirationTime&gt;2021-06-09T13:13:37.152-03:00&lt;/expirationTime&gt;\n    &lt;/header&gt;\n    &lt;credentials&gt;\n        &lt;token&gt;PD94bWwgdmVyc2lv...8L3Nzbz4K&lt;/token&gt;\n        &lt;sign&gt;j/dCKthzdFDsMuEMpaeb4D3H0/FbRaAngHHcmnABZdbz62wE7LOaDy4mYD8MYGMTgw6KZ+keBnNIVQRPQUqhyMfZJTx9/f75m1OOYY8H9Io0tREzz9hKQjJYY2wqUVMoENMfNxkMwS64e+KHwo/OHymCY/GGtcO3m2JsaksabLs=&lt;/sign&gt;\n    &lt;/credentials&gt;\n&lt;/loginTicketResponse&gt;\n</loginCmsReturn></loginCmsResponse></soapenv:Body></soapenv:Envelope>'
================================================================================
Grabando TA en /mnt/pyafipws/.venv3/lib/python3.8/site-packages/PyAfipWs-3.8.b_2537_-py3.8.egg/pyafipws/cache/TA-2b4277f5962bd2cb0265c0fac4b32304.xml...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<loginTicketResponse version="1.0">
    <header>
        <source>CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239</source>
        <destination>SERIALNUMBER=CUIT 20267565393, CN=reingart2019pub</destination>
        <uniqueId>1103203105</uniqueId>
        <generationTime>2021-06-09T01:13:37.152-03:00</generationTime>
        <expirationTime>2021-06-09T13:13:37.152-03:00</expirationTime>
    </header>
    <credentials>
        <token>PD94bWwg....</token>
        <sign>j/dCKthzdFDsMuEMpaeb4D3H0/FbRaAngHHcm....GGtcO3m2JsaksabLs=</sign>
    </credentials>
</loginTicketResponse>

Source: CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239
UniqueID Time: 1103203105
Generation Time: 2021-06-09T01:13:37.152-03:00
Expiration Time: 2021-06-09T13:13:37.152-03:00
Expiro? False

reingart added 5 commits June 9, 2021 02:47
Exception in line: `bio_in = _lib.BIO_new_mem_buf(tra, len(tra))`:
````
TypeError: initializer for ctype 'void *' must be a cdata pointer, not str
TypeError: initializer for ctype 'void *' must be a cdata pointer, not unicode
```

Signed-off-by: Mariano Reingart <reingart@gmail.com>
Signed-off-by: Mariano Reingart <reingart@gmail.com>
Signed-off-by: Mariano Reingart <reingart@gmail.com>
Signed-off-by: Mariano Reingart <reingart@gmail.com>
Signed-off-by: Mariano Reingart <reingart@gmail.com>
Signed-off-by: Nicolás Sandoval <nicolassandovalunm@gmail.com>
@chazuttu chazuttu self-requested a review June 10, 2021 05:35
@NicolasSandoval NicolasSandoval merged commit 7d6c9a5 into main Jun 10, 2021
Copy link
Collaborator

@chazuttu chazuttu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created issue chazuttu/pyafipws#13

@chazuttu chazuttu mentioned this pull request Jun 11, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants