詰まったのでメモします
前提
- Ruby: 2.7
- Faraday: 2.2.0
コード
# urlは通信先のURL
url = 'https://example.com'
connection = Faraday.new(url: url) do |faraday|
faraday.request :url_encoded
faraday.adapter :net_http
# ファイル名は各自のファイル名
faraday.ssl.client_cert = OpenSSL::X509::Certificate.new(File.read('ssl_client.crt'))
builder.ssl.client_key = OpenSSL::PKey::RSA.new(File.read('ssl_client.key'))
end
connection.get(url) do |req|
req.headers['Content-type'] = 'application/json'
end