Created
July 19, 2022 09:24
-
-
Save obahareth/bf7568dbc4796d42ad894387eb217ac7 to your computer and use it in GitHub Desktop.
An example on how to configure Faraday for SSL using client certificates, a private key, and a certificate authority file. This can help if you're getting errors like: TypeError (wrong argument type String (expected OpenSSL/X509))
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Taken from https://gist.github.com/mdeiters/975231?permalink_comment_id=3015720#gistcomment-3015720 | |
def self.ping | |
connection = Faraday::Connection.new 'https://host:443/ping', ssl: { | |
ca_file: 'config/credentials/ROOT_CA.cer', | |
client_key: OpenSSL::PKey::RSA.new(File.read('config/credentials/client.key')), | |
client_cert: OpenSSL::X509::Certificate.new(File.read('config/credentials/agent.cer')) | |
} | |
connection.get.body | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment