Git Product home page Git Product logo

Comments (21)

eeng avatar eeng commented on August 19, 2024

Hola @lucasAranda,

Mirá, no me pasó nunca pero pareciera que el problema está antes del WSFE. La conexión con el WSAA funciona? Podés probar si baja bien el WSDL con:

Savon.client(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl', soap_version: 2, ssl_version: :TLSv1_2, log: true, log_level: :debug).operations

Si ahí ya te tira el error, quizás hay algún problema con los certificados de tu máquina (no los de la AFIP que se usan después para el token de acceso). Podés probar con curl:

curl -vvv https://wsaahomo.afip.gov.ar/ws/services/LoginCms\?wsdl

También intentá lo mismo con el WSDL del WSFE así vamos descartando opciones: https://wswhomo.afip.gov.ar/wsfev1/service.asmx?WSDL

from afipws.

lucasAranda avatar lucasAranda commented on August 19, 2024

Hola @eeng muchas gracias por tu respuesta

Probé la linea:
Savon.client(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl', soap_version: 2, ssl_version: :TLSv1_2, log: true, log_level: :debug).operations
Y obtuuve el siguiente error:
D, [2020-08-03T11:10:06.516469 #14256] DEBUG -- : HTTPI TLSv1_2/peer GET request to wsaahomo.afip.gov.ar (net_http) Traceback (most recent call last): 1: from (irb):1 HTTPI::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain))

Qué puede ser el problema con los certificados de mi máquina?

from afipws.

eeng avatar eeng commented on August 19, 2024

De nada @lucasAranda. Qué raro, te detecta un self signed certificate y no debería.

Intentá entrar desde Chrome a https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl. Debería acceder con conexión segura, y si clickeas en el candadito verde debería decir que el certificado es válido:

Screen Shot 2020-08-03 at 11 37 26

Si eso no pasa, quizás tenés los certificados de tu SO desactualizados. Tendrías que investigar como actualizarlos en tu plataforma y eso lo debería solucionar.

En cualquier caso, podés saltear la validación de SSL si querés (aunque no es recomendado en producción) pasándole ssl_verify_mode a Savon:

ws = Afipws::WSFE.new(env: :development, ..., savon: {ssl_verify_mode: :none})

from afipws.

lucasAranda avatar lucasAranda commented on August 19, 2024

Si, el certificado es valido.
Pero al consultar con el ws agregando la opción savon: {ssl_verify_mode: :none} me devuelve el error original:
HTTPI::SSLError (SSL_connect returned=1 errno=0 state=error: sslv3 alert handshake failure)

Puede haber algún problema relacionado a los certificados que tengo de AFIP y los saltos de linea de los archivos?

from afipws.

eeng avatar eeng commented on August 19, 2024

Qué raro que no te funcione con el ssl_verify_mode... Y si lo agregás directamente al Savon.client?:

Savon.client(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl', soap_version: 2, ssl_version: :TLSv1_2, log: true, log_level: :debug, ssl_verify_mode: :none).operations
# => [:login_cms]

Estás en Windows?

from afipws.

lucasAranda avatar lucasAranda commented on August 19, 2024

Estoy usando Linux. Linux Mint 19.3 Tricia.
El problema lo empecé a tener luego de formatear e instalar esta versión ya que de cierta forma perdí los certificados que tenía configurados para la otra versión que tenía instalada (Linux Mint 17.2)
Te explico como es la ejecución que realizo para consultar el ultimo número de comprobante por ejemplo.

Tengo los archivos de certificados en la configuración del entorno (development.rb):
config.afip = { use_sandbox: true, private_key: File.read("config/afip/development/private.key"), certificate: File.read("config/afip/development/certificate.crt"), cuit: File.read("config/afip/development/cuit") }

Luego para hacer la consulta ejecuto las siguientes lineas:
afip_config = Rails.configuration.afip`

env = afip_config[:use_sandbox] ? "development" : Rails.env

ws = Afipws::WSFE.new env: env, cuit: afip_config[:cuit], key: afip_config[:private_key], cert: afip_config[:certificate]

ws.ultimo_comprobante_autorizado pto_vta: 1, cbte_tipo: 1

Y al hacer la consulta me devuelve el error de handshake.

from afipws.

eeng avatar eeng commented on August 19, 2024

Está perfecto como lo estás haciendo.

Pero me parece que el problema no tiene que ver con el certificado AFIP de development que le pasás ahí a WSFE.new, sino que todo indica que está antes (en el SO o en la instalación de Ruby). La gem lo primero que hace es acceder al WSDL, y luego recién usa la key y crt en un método del WS. En tu caso ya falla en el primer paso (al establecer la conexión para bajar el WSDL), con lo cual nunca llega al segundo, me explico?
Es más, si fuera problema del key o crt, no tiraría ese error en la gem HTTPI, sino que vendría una respuesta del servidor de la AFIP, encapsulada en un WSError.

Ni bien tenga un tiempito voy a probar con esa distribución de Linux a ver si encuentro algo raro. Mientras tanto contame si con curl te funciona o también te tira error de SSL:

curl -vvv https://wsaahomo.afip.gov.ar/ws/services/LoginCms\?wsdl

from afipws.

lucasAranda avatar lucasAranda commented on August 19, 2024

Te paso lo que me devolvió:

  • Trying 200.1.116.66...
  • TCP_NODELAY set
  • Connected to wsaahomo.afip.gov.ar (200.1.116.66) port 443 (#0)
  • ALPN, offering h2
  • ALPN, offering http/1.1
  • successfully set certificate verify locations:
  • CAfile: /etc/ssl/certs/ca-certificates.crt
    CApath: /etc/ssl/certs
  • TLSv1.3 (OUT), TLS handshake, Client hello (1):
  • TLSv1.3 (IN), TLS handshake, Server hello (2):
  • TLSv1.2 (IN), TLS handshake, Certificate (11):
  • TLSv1.2 (IN), TLS handshake, Server key exchange (12):
  • TLSv1.2 (IN), TLS handshake, Server finished (14):
  • TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
  • TLSv1.2 (OUT), TLS change cipher, Client hello (1):
  • TLSv1.2 (OUT), TLS handshake, Finished (20):
  • TLSv1.2 (IN), TLS handshake, Finished (20):
  • SSL connection using TLSv1.2 / DHE-RSA-AES256-GCM-SHA384
  • ALPN, server did not agree to a protocol
  • Server certificate:
  • subject: C=AR; postalCode=C1086AAD; 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=Unified Communications; CN=wsaahomo.afip.gov.ar
  • start date: Feb 20 00:00:00 2019 GMT
  • expire date: Mar 20 23:59:59 2021 GMT
  • subjectAltName: host "wsaahomo.afip.gov.ar" matched cert's "wsaahomo.afip.gov.ar"
  • issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Organization Validation Secure Server CA
  • SSL certificate verify ok.

GET /ws/services/LoginCms?wsdl HTTP/1.1
Host: wsaahomo.afip.gov.ar
User-Agent: curl/7.58.0
Accept: /

< HTTP/1.1 200 OK
< Date: Mon, 03 Aug 2020 17:25:38 GMT
< Content-Type: text/xml;charset=utf-8
< Set-Cookie: TS01b14f84=0145b27a9751cf5fb720f10a40dd1eea2b4cff3607b77e8599f499f848e6e18b1df9cfc9d8; Path=/
< Transfer-Encoding: chunked>

<wsdl:definitions targetNamespace="https://wsaahomo.afip.gov.ar/ws/services/LoginCms" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="https://wsaahomo.afip.gov.ar/ws/services/LoginCms" xmlns:intf="https://wsaahomo.afip.gov.ar/ws/services/LoginCms" xmlns:tns1="http://wsaa.view.sua.dvadac.desein.afip.gov" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

wsdl:types
schema elementFormDefault="qualified" targetNamespace="http://wsaa.view.sua.dvadac.desein.afip.gov" xmlns="http://www.w3.org/2001/XMLSchema">
import namespace="https://wsaahomo.afip.gov.ar/ws/services/LoginCms"/>
element name="loginCms">
complexType>

element name="in0" type="xsd:string"/>
/sequence>
/complexType>
/element>
element name="loginCmsResponse">
complexType>
sequence>
element name="loginCmsReturn" type="xsd:string"/>
/sequence>
/complexType>
/element>
/schema>
schema elementFormDefault="qualified" targetNamespace="https://wsaahomo.afip.gov.ar/ws/services/LoginCms" xmlns="http://www.w3.org/2001/XMLSchema">
complexType name="LoginFault">
sequence/>
/complexType>
element name="fault" type="impl:LoginFault"/>
/schema>
</wsdl:types>

<wsdl:message name="loginCmsRequest">

  <wsdl:part element="tns1:loginCms" name="parameters">

  </wsdl:part>

</wsdl:message>

<wsdl:message name="LoginFault">

  <wsdl:part element="impl:fault" name="fault">

  </wsdl:part>

</wsdl:message>

<wsdl:message name="loginCmsResponse">

  <wsdl:part element="tns1:loginCmsResponse" name="parameters">

  </wsdl:part>

</wsdl:message>

<wsdl:portType name="LoginCMS">

  <wsdl:operation name="loginCms">

     <wsdl:input message="impl:loginCmsRequest" name="loginCmsRequest">

   </wsdl:input>

     <wsdl:output message="impl:loginCmsResponse" name="loginCmsResponse">

   </wsdl:output>

     <wsdl:fault message="impl:LoginFault" name="LoginFault">

   </wsdl:fault>

  </wsdl:operation>

</wsdl:portType>

<wsdl:binding name="LoginCmsSoapBinding" type="impl:LoginCMS">

  <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

  <wsdl:operation name="loginCms">

     <wsdlsoap:operation soapAction=""/>

     <wsdl:input name="loginCmsRequest">

        <wsdlsoap:body use="literal"/>

     </wsdl:input>

     <wsdl:output name="loginCmsResponse">

        <wsdlsoap:body use="literal"/>

     </wsdl:output>

     <wsdl:fault name="LoginFault">

        <wsdlsoap:fault name="LoginFault" use="literal"/>

     </wsdl:fault>

  </wsdl:operation>

</wsdl:binding>

<wsdl:service name="LoginCMSService">

  <wsdl:port binding="impl:LoginCmsSoapBinding" name="LoginCms">

     <wsdlsoap:address location="https://wsaahomo.afip.gov.ar/ws/services/LoginCms"/>

  </wsdl:port>

</wsdl:service>

</wsdl:definitions>

  • Connection #0 to host wsaahomo.afip.gov.ar left intact

from afipws.

eeng avatar eeng commented on August 19, 2024

Ahí probé en un Linux Mint 19.3. Luego de instalar ruby 2.5.1p57 (con apt) y la gem, funciona correctamente.

Savon.client(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl', soap_version: 2, ssl_version: :TLSv1_2).operations
# => [:login_cms]

Ahora, logré reproducir tu error exacto eliminando todos los certs de /etc/ssl/certs:

Savon.client(wsdl: 'https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl', soap_version: 2, ssl_version: :TLSv1_2).operations
# ...
# HTTPI::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain))

Si luego restauro los certificados con sudo update-ca-certificates vuelve a funcionar. Así que pareciera ser un problema con los certificados de tu Linux. También funcionó agregando el ssl_verify_mode: :none como te decía arriba.

Fijate si te sirve y cualquier cosa avisame. Saludos.

from afipws.

lucasAranda avatar lucasAranda commented on August 19, 2024

Muchas gracias @eeng
Seguramente es un problema con mis certificados de Linux.

Cómo debería configurarlos?

from afipws.

eeng avatar eeng commented on August 19, 2024

De nada @lucasAranda.

Si el update-ca-certificates ni el ssl_verify_mode: :none te funciona, ya no sabría qué decirte... No tengo experiencia con ese LInux. Quizás probar con una instalación nueva, ej. en un Vagrant como hice yo: https://app.vagrantup.com/mrlesmithjr/boxes/linuxmint-19.3 y ver si hay alguna diferencia con tu instalación. O probar con otra distribución. Vas a tener que seguir investigando.

Cierro este issue ya que no está relacionado con la gem.
Cualquier otra consulta aquí estamos. Saludos.

from afipws.

chupetoide avatar chupetoide commented on August 19, 2024

Mismo issue en MacOS y con el setting ssl_verify_mode: :none:

Savon options: {:wsdl=>"https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl", :ssl_verify_mode=>:none}
HTTPI::SSLError: SSL_connect returned=1 errno=0 state=error: sslv3 alert handshake failure
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/httpi-2.4.4/lib/httpi/adapter/net_http.rb:55:in `rescue in request'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/httpi-2.4.4/lib/httpi/adapter/net_http.rb:41:in `request'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/httpi-2.4.4/lib/httpi.rb:161:in `request'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/httpi-2.4.4/lib/httpi.rb:127:in `get'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/wasabi-3.5.0/lib/wasabi/resolver.rb:43:in `load_from_remote'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/wasabi-3.5.0/lib/wasabi/resolver.rb:33:in `resolve'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:142:in `xml'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:160:in `parse'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:147:in `parser'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/wasabi-3.5.0/lib/wasabi/document.rb:64:in `soap_actions'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/savon-2.11.2/lib/savon/operation.rb:22:in `ensure_exists!'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/savon-2.11.2/lib/savon/operation.rb:15:in `create'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/savon-2.11.2/lib/savon/client.rb:32:in `operation'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/gems/savon-2.11.2/lib/savon/client.rb:36:in `call'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/bundler/gems/afipws-e9fd4cf6cfbc/lib/afipws/client.rb:9:in `request'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/vendor/bundle/ruby/2.0.0/bundler/gems/afipws-e9fd4cf6cfbc/lib/afipws/wsaa.rb:50:in `login'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/app/models/afip/afip_login.rb:42:in `negotiate_new_token'
	from /Volumes/sdCard/Workspaces/Github/Octavo/eighthfloor/app/models/afip/afip_login.rb:15:in `get_token'

Consumiendo el endpoint en forma directa parece funcionar sin problema:

HTTPI.get("https://wsaahomo.afip.gov.ar/ws/services/LoginCms?wsdl", adapter = nil)

from afipws.

marcoschicote avatar marcoschicote commented on August 19, 2024

Me pasa lo mismo que menciona @chupetoide

from afipws.

chupetoide avatar chupetoide commented on August 19, 2024

En mi caso lo resolvimos cambiando la versión de ssl por SSLv23

@client = Savon.client savon_options.reverse_merge(soap_version: 2, ssl_version: :SSLv23)

from afipws.

marcoschicote avatar marcoschicote commented on August 19, 2024

En mi caso lo resolvimos cambiando la versión de ssl por SSLv23

@client = Savon.client savon_options.reverse_merge(soap_version: 2, ssl_version: :SSLv23)

Tendrá algo que ver con esto entonces? https://github.com/eeng/afipws/pull/17/files

A su vez, al entrar a https://www.afip.gob.ar/ws/ está este mensaje:

El día 01/10/2020 a las 16:00 se procederá a actualizar el certificado correspondiente al sitio productivo de WSAA: wsaa.afip.gov.ar, con vencimiento el 11/10/2020.
Si bien este cambio debería ser transparente, se recuerda que las Autoridades Certificantes empleadas por AFIP para los sitios seguros de webservices, se encuentran en este micrositio.
Si surgieran errores al 01/10/2020, es muy probable que estén relacionados a la configuración de certificados de la aplicación cliente. En ese caso se deberá corroborar la correcta configuración en base a los estándares.

from afipws.

chupetoide avatar chupetoide commented on August 19, 2024

Parece que si

from afipws.

marcoschicote avatar marcoschicote commented on August 19, 2024

Creo que el tema viene por acá: https://stackoverflow.com/a/36417794/723199
Yo lo empecé a ver porque actualicé una imagen de docker de ruby y con eso openssl, pero el problema es de certificado de AFIP. Como tengo un contacto semi adentro lo reporté, veremos qué pasa.

from afipws.

fquintana avatar fquintana commented on August 19, 2024

Hola, mismo error por aqui en Ubuntu.
funcionaba todo bien hasta hace 15 dias y empezo a tirar este error

SSL_connect returned=1 errno=0 state=error: sslv3 alert handshake failure

from afipws.

marcoschicote avatar marcoschicote commented on August 19, 2024

Hola, mismo error por aqui en Ubuntu.
funcionaba todo bien hasta hace 15 dias y empezo a tirar este error

SSL_connect returned=1 errno=0 state=error: sslv3 alert handshake failure

Yo lo reproduje desde la consola así:

curl -vvv https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL

Para solucionarlo temporalmente:

curl -vvv --cipher 'DEFAULT:!DH' https://aws.afip.gov.ar/sr-padron/webservices/personaServiceA5?WSDL

Para solucionarlo definitivamente (aunque probablemente no sea lo más recomendable):

echo "CipherString=DEFAULT@SECLEVEL=1" >> /etc/ssl/openssl.cnf

Más data en https://stackoverflow.com/questions/36417224/openssl-dh-key-too-small-error/36417794#36417794

from afipws.

fquintana avatar fquintana commented on August 19, 2024

Gracias Marcos, pero persiste el problema con "CipherString=DEFAULT@SECLEVEL=1" en la config

from afipws.

fquintana avatar fquintana commented on August 19, 2024

Estaba usando afipws v1.3.1, actualice a v2.0.0 y voila! Andando nuevamente.

from afipws.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.