I'm trying to consume a web service with a certificate, sending a XML/SOAP, via SSL with mutual authentication. I've tried savon
and net/http
, but I'm stopped with the same error:
SSL_CTX_use_PrivateKey: key values mismatch (HTTPI::SSLError)
net/http:
uri = URI.parse('https://homologacao.sefaz.mt.gov.br/nfews/v2/services/NfeStatusServico2?wsdl')
pem = File.read("cert/cert.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
savon:
WSDL_URL = 'https://homologacao.sefaz.mt.gov.br/nfews/v2/services/NfeStatusServico2?wsdl'
client = Savon.client(
wsdl: WSDL_URL,
ssl_version: :SSLv3,
ssl_verify_mode: :peer,
ssl_cert_file: 'cert/cert.pem',
ssl_cert_key_file: 'cert/private_key.pem',
# ssl_cert_key_password: '123456789',
env_namespace: :soap,
namespace_identifier: nil
)
response = client.call(:nfeStatusServicoNF2, message: "test")
Is there a solution? Thanks!