Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

563
Views
OpenSSL::SSL::SSLError: el certificado ca del servidor del cliente de Ruby no funciona mientras funcionaba con curl

Obtuve el certificado del cliente para conectarme con su VPN, pero no funciona con el código ruby mientras funcionaba con el comando curl. El comando Curl es el siguiente:

 curl --cacert cert.cer -d '{"acb": 123 }' -H 'Content-Type: application/json' 'https://demo.com'

En ruby, intento hacer lo siguiente para conectar las API de cliente que se nos proporcionan para las transacciones.

 require 'net/http' require 'json' require 'uri' full_url = "https://demo.com" uri = URI.parse(full_url) data = { "acb": 123 } headers = { 'Content-Type' => "application/json" } http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true raw = File.read("path_to_the_certificate") http.cert = OpenSSL::X509::Certificate.new(raw) request = Net::HTTP::Post.new(uri.request_uri, headers) request.body = data.to_json response = http.request(request) puts response.code puts response.body

También intentamos pasar el certificado de nuestro servidor de la siguiente manera, pero tampoco funciona

 http.ca_path='/etc/pki/tls/certs' http.ca_file='/etc/pki/tls/certs/cert.cer' http.cert = OpenSSL::X509::Certificate.new(File.read("/path/client.crt")) http.key = OpenSSL::PKey::RSA.new(File.read("/path/client.key"))

Obteniendo el siguiente error mientras

 OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate))
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Creo que el problema con su certificado autofirmado. Falla la verificación. Sin embargo, puede desactivarlo manualmente con

 http.verify_mode = OpenSSL::SSL::VERIFY_NONE

verificar_modo[RW]

Establece las banderas para la verificación de la certificación del servidor al comienzo de la sesión SSL/TLS.

OpenSSL::SSL::VERIFY_NONE o OpenSSL::SSL::VERIFY_PEER son aceptables.

de https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html

Traté de replicarlo localmente y funcionó con esta solución.

over 4 years ago · Santiago Trujillo Report

0

Debería ser que el certificado vpn esté autofirmado, debe especificar su propio cacert, por lo que especifica el archivo cacert como el archivo utilizado por el curl anterior, no el archivo cacert que viene con el sistema

agrega esta línea:

 http.ca_file = "cacert filename"

Me gusta esto:

 require 'net/http' require 'json' require 'uri' full_url = "https://localhost/test.html" uri = URI.parse(full_url) data = { "acb": 123 } headers = { 'Content-Type' => "application/json" } http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true # You need to specify the cacert file used for curl above (filename: cert.cer) http.ca_file = "/root/myca/cacert.crt" request = Net::HTTP::Post.new(uri.request_uri, headers) request.body = data.to_json response = http.request(request) puts response.code puts response.body
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!