SSL/HTTPS request error

Hello guys,

I’m need to connect with a webservice via ssl with a certificate. I have
a certificate .pfx and i convert to .pem.

I’m using net/http to consume the webservice but failed. I’ve tried use
savon too, but stopped in the same error.

My Code

NET/HTTP
uri =
URI.parse(‘https://homologacao.sefaz.mt.gov.br/nfews/v2/services/NfeStatusServico2?wsdl’)
pem = File.read(“cert/certificate.pem”)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.cert = OpenSSL::X509::Certificate.new(pem)
http.key = OpenSSL::PKey::RSA.new(pem)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER

http.start

Error:

/net/http.rb:895:in `initialize’: SSL_CTX_use_PrivateKey: key values
mismatch (OpenSSL::SSL::SSLError)

Anyone can help me?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs