¿Webservice caído?

2,364 views
Skip to first unread message

Andres Misiak

unread,
Feb 3, 2015, 2:52:07 PM2/3/15
to pyaf...@googlegroups.com
Hola a todos, les escribo porque desde hoy a las 10 de la mañana que los servidores del AFIP están rechazando un montón de solicitudes para hacer facturas electrónicas con rece1.py.

Lo extraño es que recibí estos 2 mensajes de errores diferentes, cuando generalmente solo me llegan timeouts:

-error: [Errno 104] Connection reset by peer
-
SSLError: _ssl.c:495: The handshake operation timed out

El resultado de la consulta con el parámetro dummy es todo None, así que creo que es tema del AFIP, pero si algún otro también tuvo problemas o incluso si les funcionó bien, me voy a quedar más tranquilo si no soy el único con este problema.

AppServerStatus None
DbServerStatus None
AuthServerStatus None

Gracias
Andres Misiak

Leonardo Garcia

unread,
Feb 3, 2015, 4:54:49 PM2/3/15
to pyaf...@googlegroups.com
Mira, yo facture temprano y luego dejo de funcionar. Hasta ahora no tuve novedades. Y yo uso SOAP desde PHP asi que tampoco es la lib pyafipws

Saludos y ojala se solucione rapido.

--
Has recibido este mensaje porque estás suscrito al grupo "PyAfipWs - Factura Electrónica Libre" de Grupos de Google.
Para anular la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a pyafipws+u...@googlegroups.com.
Para publicar en este grupo, envía un correo electrónico a pyaf...@googlegroups.com.
Visita este grupo en http://groups.google.com/group/pyafipws.
Para acceder a más opciones, visita https://groups.google.com/d/optout.

Leonardo Garcia

unread,
Feb 3, 2015, 9:40:48 PM2/3/15
to pyaf...@googlegroups.com
Tuviste alguna novedad Andres con esto? Yo sigo igual.... 

Saludos

Andres Misiak

unread,
Feb 3, 2015, 10:04:22 PM2/3/15
to pyaf...@googlegroups.com
No, son las 00:03 del miércoles ya y sigue igual

Saludos.

Leonardo Garcia

unread,
Feb 4, 2015, 10:56:21 AM2/4/15
to pyaf...@googlegroups.com
Andres, lo hice funcionar, pero era porque habia problemas con la version de SSL que por defecto utilizaba mi coneccion

Vos? Lo solucionaste?

Saludos

2015-02-04 9:08 GMT-03:00 Leonardo Garcia <col...@gmail.com>:
Buen dia, nadie mas tuvo este inconveniente? Yo sigo sin poder conectar con el webservice.

Que bajon...

Lucio Itecnis

unread,
Feb 4, 2015, 11:17:26 AM2/4/15
to pyaf...@googlegroups.com
Buenas tardes,

estamos teniendo el mismo problema desde ayer, no solo al solicitar CAE si no al intentar obtener el ticket de acceso.
Nos comunicamos con la AFIP, pero por el momento no hemos logrado resolver el inconveniente.

La versión de SSL que estamos utilizando es: 1.01e
Qué versión están utilizando Leonardo?

Muchas gracias, saludos

Patricio Molina

unread,
Feb 4, 2015, 11:34:12 AM2/4/15
to pyaf...@googlegroups.com
Hola a todos

En nuestro caso estamos con el mismo inconveniente desde esta mañana. Si alguien sabe cómo solucionarlo, más que agradecido.

Usamos OpenSSL 1.0.1f bajo Ubuntu 14.04 LTS.

Saludos,
Patricio 

Leonardo Garcia

unread,
Feb 4, 2015, 11:56:17 AM2/4/15
to pyaf...@googlegroups.com
Yo lo solucione forzando a sslv3. Este era el del bug eso me llama la atencion ahora que lo pienso. Pero fue la unica forma de comunicar con el servidor.

Saludos

--
Has recibido este mensaje porque estás suscrito al grupo "PyAfipWs Factura Electrónica Libre y temas relacionados AFIP ARBA ANMAT" de Grupos de Google.

Mariano Reingart

unread,
Feb 4, 2015, 12:09:18 PM2/4/15
to pyaf...@googlegroups.com
2015-02-04 13:40 GMT-03:00 Leonardo Garcia <col...@gmail.com>:
Yo lo solucione forzando a sslv3. Este era el del bug eso me llama la atencion ahora que lo pienso. Pero fue la unica forma de comunicar con el servidor.


Parece que AFIP volvió con el problema de SSLv3 vs TLS. 
TL;DR: ver abajo para la solución provisoria, forzando USE_SSLv3 = True en pysimplesoap/transport.py

Ahora el servidor de AFIP no soportaría TLSv1.2, solo TLSv1.0 y aparentemente la negociación falla por algún problema en la configuración del servidor, por lo que incluso herramientas estándar no funcionan:

Resolviendo servicios1.afip.gov.ar (servicios1.afip.gov.ar)... 200.1.116.53
Conectando con servicios1.afip.gov.ar (servicios1.afip.gov.ar)[200.1.116.53]:443... conectado.
No se pudo establecer la conexión SSL.

reingart@s5ultra:~/pyafipws$ gnutls-cli servicios1.afip.gov.ar
Resolving 'servicios1.afip.gov.ar'...
Connecting to '200.1.116.53:443'...
- Certificate type: X.509
 - Got a certificate list of 2 certificates.
 - Certificate[0] info:
  - subject `C=AR,postalCode=1086,ST=Ciudad Autonoma de Buenos Aires,L=Capital Federal,STREET=Hipolito Yrigoyen 370,O=ADMINISTRACION FEDERAL DE INGRESOS PUBLICOS,OU=Issued through ADMINISTRACION FEDERAL DE INGRESOS PUBLICOS E-PKI,OU=InstantSSL,CN=servicios1.afip.gov.ar', issuer `C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO High-Assurance Secure Server CA', RSA key 2048 bits, signed using RSA-SHA1, activated `2015-01-09 00:00:00 UTC', expires `2016-12-31 23:59:59 UTC', SHA-1 fingerprint `5c93fa74c12cef9e7ba93c2d068ec707545681bd'
 - Certificate[1] info:
  - subject `C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO High-Assurance Secure Server CA', issuer `C=SE,O=AddTrust AB,OU=AddTrust External TTP Network,CN=AddTrust External CA Root', RSA key 2048 bits, signed using RSA-SHA1, activated `2010-04-16 00:00:00 UTC', expires `2020-05-30 10:48:38 UTC', SHA-1 fingerprint `b9b4c7a488c0885ec1c83aa87e4ebd2b215f9fa4'
- The hostname in the certificate matches 'servicios1.afip.gov.ar'.
- Peer's certificate issuer is unknown
- Peer's certificate is NOT trusted
- Version: TLS1.0
- Key Exchange: RSA
- Cipher: ARCFOUR-128
- MAC: MD5
- Compression: NULL
- Handshake was completed

- Simple Client Mode:

GET / HTTP/1.0

*** Fatal error: A TLS packet with unexpected length was received.
*** Server has terminated the connection abnormally.

Cabe aclarar que WSAA si funciona correctamente soportando TLSv1.2 y validando el certificado (aparentemente un servidor Apache 2.2 corriendo sobre RedHat linux):

reingart@s5ultra:~/pyafipws$ gnutls-cli wsaa.afip.gov.ar
Resolving 'wsaa.afip.gov.ar'...
Connecting to '200.1.116.76:443'...
- Ephemeral Diffie-Hellman parameters
 - Using prime: 2048 bits
 - Secret key: 2047 bits
 - Peer's public key: 2038 bits
- Certificate type: X.509
 - Got a certificate list of 3 certificates.
 - Certificate[0] info:
  - subject `C=AR,postalCode=1086,ST=Ciudad Autonoma de Buenos Aires,L=Capital Federal,STREET=Hipolito Yirigoyen 370,O=ADMINISTRACION FEDERAL DE INGRESOS PUBLICOS,OU=Issued through ADMINISTRACION FEDERAL DE INGRESOS PUBLICOS E-PKI,OU=InstantSSL,CN=wsaa.afip.gov.ar', issuer `C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO High-Assurance Secure Server CA', RSA key 2048 bits, signed using RSA-SHA1, activated `2013-05-29 00:00:00 UTC', expires `2015-05-29 23:59:59 UTC', SHA-1 fingerprint `5b74f7f8af3754bed08670f942bf135cf0d4831f'
 - Certificate[1] info:
  - subject `C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO High-Assurance Secure Server CA', issuer `C=SE,O=AddTrust AB,OU=AddTrust External TTP Network,CN=AddTrust External CA Root', RSA key 2048 bits, signed using RSA-SHA1, activated `2010-04-16 00:00:00 UTC', expires `2020-05-30 10:48:38 UTC', SHA-1 fingerprint `b9b4c7a488c0885ec1c83aa87e4ebd2b215f9fa4'
 - Certificate[2] info:
  - subject `C=SE,O=AddTrust AB,OU=AddTrust External TTP Network,CN=AddTrust External CA Root', issuer `C=SE,O=AddTrust AB,OU=AddTrust External TTP Network,CN=AddTrust External CA Root', RSA key 2048 bits, signed using RSA-SHA1, activated `2000-05-30 10:48:38 UTC', expires `2020-05-30 10:48:38 UTC', SHA-1 fingerprint `02faf3e291435468607857694df5e45b68851868'
- The hostname in the certificate matches 'wsaa.afip.gov.ar'.
- Peer's certificate issuer is unknown
- Peer's certificate is NOT trusted
- Version: TLS1.2
- Key Exchange: DHE-RSA
- Cipher: AES-128-CBC
- MAC: SHA1
- Compression: NULL
- Handshake was completed

- Simple Client Mode:

GET / HTTP/1.0

HTTP/1.1 403 Forbidden
Date: Wed, 04 Feb 2015 16:52:42 GMT
Server: Apache
Accept-Ranges: bytes
Content-Length: 3985
Connection: close
Content-Type: text/html; charset=UTF-8

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
...
</html>
- Peer has closed the GnuTLS connection


Como solución provisoria (workaround), en la biblioteca pysimplesoap, modulo transport.py, se puede forzar el uso de la versión anterior de SSL:

USE_SSLv3 = True

Con esa configuración funciona OK:

reingart@s5ultra:~/pyafipws$ python rece1.py rece-mariano.ini /dummy --trace
Consultando estado de servidores...
--------------------------------------------------------------------------------
Content-length: 269
Content-type: text/xml; charset="UTF-8"

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header/>
<soap:Body>
    
</soap:Body>
</soap:Envelope>

status: 200
content-length: 424
x-powered-by: ASP.NET
x-aspnet-version: 2.0.50727
cache-control: private, max-age=0
date: Wed, 04 Feb 2015 16:55:13 GMT
content-type: text/xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><FEDummyResponse xmlns="http://ar.gov.afip.dif.FEV1/"><FEDummyResult><AppServer>OK</AppServer><DbServer>OK</DbServer><AuthServer>OK</AuthServer></FEDummyResult></FEDummyResponse></soap:Body></soap:Envelope>
================================================================================
AppServerStatus OK
DbServerStatus OK
AuthServerStatus OK

Es raro porque SSLv3 lo están retirando muchos proveedores porque ya no es seguro...

Sds

Andres Misiak

unread,
Feb 4, 2015, 2:32:01 PM2/4/15
to pyaf...@googlegroups.com
A mi no me funcionó, me di cuenta que tenía una versión más antigua, así que actualicé a esta última, sin embargo no me funciona. Estoy revisando el pyafipws también para ver si tengo algo viejo, ¿se les ocurre algo que pueda probar?

Gracias.
Saludos.
Andres Misiak


Mariano Reingart

unread,
Feb 4, 2015, 3:24:59 PM2/4/15
to pyaf...@googlegroups.com
2015-02-04 16:31 GMT-03:00 Andres Misiak <andres...@gmail.com>:
A mi no me funcionó, me di cuenta que tenía una versión más antigua, así que actualicé a esta última, sin embargo no me funciona. Estoy revisando el pyafipws también para ver si tengo algo viejo, ¿se les ocurre algo que pueda probar?


¿Que sistema operativo tienen?

Recien subi los cambios para compatibilidad con SSLv3/TLSv1 a la biblioteca PySimpleSoap (commit 0c5af8fea290).
Podes bajar la actualización e instalarla:


Podés probar lo siguiente:

reingart@s5ultra:~/pyafipws$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.1f 6 Jan 2014'

También podrías probar el modo "compatibilidad" que deshabilita TLS v1.1 y v1.2: 

gnutls-cli --priority NORMAL:%COMPAT:-VERS-TLS1.2:-VERS-TLS1.1 servicios1.afip.gov.ar


Para más información ver los reportes en las distribuciones de linux:
También podes ver los hilos anteriores que proponen ajustes similres:

Avisanos si te funciona, así cierro este tema.

Andres Misiak

unread,
Feb 4, 2015, 3:55:38 PM2/4/15
to pyaf...@googlegroups.com
Tengo un Ubuntu 14.04.1 LTS en una instancia de Amazon.

ubuntu@ip-10-252-138-82:/sites/tools$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.1f 6 Jan 2014'


La conexión así me da bien
ubuntu@ip-10-252-138-82:/sites/tools$ wget --secure-protocol=TLSv1 https://servicios1.afip.gov.ar/wsfev1/service.asmx?WSDL
Connecting to servicios1.afip.gov.ar (servicios1.afip.gov.ar)|200.1.116.53|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 68967 (67K) [text/xml]
service.asmx?WSDL: Permission denied


Pero con gnutls-cli me tira un error de TLS
ubuntu@ip-10-252-138-82:/sites/tools$ sudo gnutls-cli --priority NORMAL:%COMPAT:-VERS-TLS1.2:-VERS-TLS1.1 servicios1.afip.gov.ar
Resolving 'servicios1.afip.gov.ar'...
Connecting to '200.1.116.53:443'...
- Certificate type: X.509
 - Got a certificate list of 2 certificates.
 - Certificate[0] info:
  - subject `C=AR,postalCode=1086,ST=Ciudad Autonoma de Buenos Aires,L=Capital Federal,STREET=Hipolito Yrigoyen 370,O=ADMINISTRACION FEDERAL DE INGRESOS PUBLICOS,OU=Issued through ADMINISTRACION FEDERAL DE INGRESOS PUBLICOS E-PKI,OU=InstantSSL,CN=servicios1.afip.gov.ar', issuer `C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO High-Assurance Secure Server CA', RSA key 2048 bits, signed using RSA-SHA1, activated `2015-01-09 00:00:00 UTC', expires `2016-12-31 23:59:59 UTC', SHA-1 fingerprint `5c93fa74c12cef9e7ba93c2d068ec707545681bd'
 - Certificate[1] info:
  - subject `C=GB,ST=Greater Manchester,L=Salford,O=COMODO CA Limited,CN=COMODO High-Assurance Secure Server CA', issuer `C=SE,O=AddTrust AB,OU=AddTrust External TTP Network,CN=AddTrust External CA Root', RSA key 2048 bits, signed using RSA-SHA1, activated `2010-04-16 00:00:00 UTC', expires `2020-05-30 10:48:38 UTC', SHA-1 fingerprint `b9b4c7a488c0885ec1c83aa87e4ebd2b215f9fa4'
- The hostname in the certificate matches 'servicios1.afip.gov.ar'.
- Peer's certificate issuer is unknown
- Peer's certificate is NOT trusted
- Version: TLS1.0
- Key Exchange: RSA
- Cipher: ARCFOUR-128
- MAC: MD5
- Compression: NULL
- Handshake was completed

- Simple Client Mode:

*** Fatal error: A TLS packet with unexpected length was received.
*** Server has terminated the connection abnormally.

Voy a ver si puedo averiguar más por ahí

Lo malo es que en Noviembre cuando salió todo el tema del SSLv3 recuerdo que hicimos cambios en el servidor, puede venir por ahí el tema.

Saludos.
Andres Misiak

Mariano Reingart

unread,
Feb 4, 2015, 4:49:27 PM2/4/15
to pyaf...@googlegroups.com
A mi también me da el "Fatal error:"  pero si pido una página me la devuelve ...

Voy a ver si puedo averiguar más por ahí


Python 2.7 no usa GNUTLS, sino OpenSSL, podes probar ejecutando:
 
openssl s_client -tls1 -connect servicios1.afip.gov.ar:443

Cuando abre la conexión, tenes que pedir una página para ver si funciona, por ej:

GET /wsfev1/service.asmx?WSDL HTTP/1.0

(enviar también la linea en blanco)

Debería funcionarte, tengo el mismo S.O. y versiones de las bibliotecas.
 
Lo malo es que en Noviembre cuando salió todo el tema del SSLv3 recuerdo que hicimos cambios en el servidor, puede venir por ahí el tema.


Te diría que vayas más por el lado de actualizar pysimplesoap (la biblioteca de webservices) donde hice los ajustes para forzar SSLv3 o TLSv1:

Andres Misiak

unread,
Feb 4, 2015, 4:59:52 PM2/4/15
to pyaf...@googlegroups.com
Mariano sos un genio total, el comando pip para actualizar el pysimplesoap solucionó el problema
Mil gracias
Andres Misiak


El martes, 3 de febrero de 2015, 16:52:07 (UTC-3), Andres Misiak escribió:

Lucio Itecnis

unread,
Feb 4, 2015, 5:37:33 PM2/4/15
to pyaf...@googlegroups.com
Buenas tardes Mariano, 

por lo que pude ver los cambios los hiciste para httplib2 y pycurl y como era de esperarse, nosotros utilizamos urllib2...

_Creo_ haberlo solucionado agregando algo similar a esto:

import httplib
import socket
class TLS1Connection(httplib.HTTPSConnection):
"""Like HTTPSConnection but more specific"""
def __init__(self, host, **kwargs):
httplib.HTTPSConnection.__init__(self, host, **kwargs)
 
def connect(self):
"""Overrides HTTPSConnection.connect to specify TLS version"""
# Standard implementation from HTTPSConnection, which is not
# designed for extension, unfortunately
sock = socket.create_connection((self.host, self.port),
self.timeout, self.source_address)
if getattr(self, '_tunnel_host', None):
self.sock = sock
self._tunnel()
 
# This is the only difference; default wrap_socket uses SSLv23
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file,
ssl_version=ssl.PROTOCOL_TLSv1)
 
class TLS1Handler(urllib2.HTTPSHandler):
"""Like HTTPSHandler but more specific"""
def __init__(self):
urllib2.HTTPSHandler.__init__(self)
 
def https_open(self, req):
return self.do_open(TLS1Connection, req)

class urllib2Transport(TransportBase):
...
    
def __init__(self, timeout=None, proxy=None, cacert=None, sessions=False):
...
        handlers = [TLS1Handler()]

        if sessions:
            from cookielib import CookieJar
            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(CookieJar()))

        self.request_opener = urllib2.build_opener(*handlers).open
        

Muchas gracias Mariano, saludos

--
Has recibido este mensaje porque estás suscrito a un tema del grupo "PyAfipWs Factura Electrónica Libre y temas relacionados AFIP ARBA ANMAT" de Grupos de Google.
Para anular la suscripción a este tema, visita https://groups.google.com/d/topic/pyafipws/kJTAH4jLEEo/unsubscribe.
Para anular la suscripción a este grupo y a todos sus temas, envía un correo electrónico a pyafipws+u...@googlegroups.com.

Para publicar en este grupo, envía un correo electrónico a pyaf...@googlegroups.com.
Visita este grupo en http://groups.google.com/group/pyafipws.
Para acceder a más opciones, visita https://groups.google.com/d/optout.



--
Lucio Nardelli
Imágenes integradas 2
 
                     La simplicidad es la sofisticación suprema

daniel musante

unread,
Jul 3, 2020, 2:55:53 PM7/3/20
to PyAfipWs Factura Electrónica Libre y temas relacionados AFIP ARBA ANMAT
Por favor Leonardo Garcia , estas usando SOPA y PHP para Factura electronica, cambiastes a TLS1.2, me podes indicar como invocas al webservice en homologacion porque nopuedo conectarme...

    Muchas gracias

daniel 
Reply all
Reply to author
Forward
0 new messages