title: POST Requests with Ruby Faraday OpenSSL PKCS12
body: <p>Good day!</p>
  
  <p>I am trying to send POST requests to a server via ssl connection with .p12 certificate from Windows 7 with Ruby's Faraday library.</p>
  
  <p>Ruby's version is ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32]</p>
  
  <p>Faraday gem's version are: faraday (0.14.0, 0.9.2)</p>
  
  <p>1) I have a folder with the following cert files:</p>
  
  <ul>
  <li>[cert_name].crt,</li>
  <li>[cert_name].csr,</li>
  <li>[cert_name].key,</li>
  <li>[cert_name].p12</li>
  </ul>
  
  <p>2) As to the code, I have the following:</p>
  
  <pre><code>require "faraday"
  require "json"
  require "openssl"
  data = [JSON_object]
  host = 'https://[domain_name]'
  url = '[string]/[string]'
  p12 = OpenSSL::PKCS12.new(File.open('[path_to_folder_with_cert_files]/[cert_name].p12', "rb").read, "[password]")
  key = p12.key
  cert = p12.certificate
  connection = Faraday::Connection.new host, :ssl =&gt; {
    :client_cert =&gt; cert,
    :client_key =&gt; key,
    :ca_file =&gt; '[path_to_folder_with_cert_files]/[cert_name].crt',
    :verify =&gt; false
  }
  puts response.status = connection.post do |req|
    req.url(url)
    req.headers['Content-Type'] = @headers["content_type"]
    req.body = data
  end
  </code></pre>
  
  <p>Response has 403 Forbidden. I have tested with no ssl connection the data, url, host parameters and the status is 200 OK.</p>
  
  <p>Please help, as I have found no tutorial / question to this particular use of Ruby's Faraday and OpenSSL::PKCS12</p>