Created
August 15, 2017 21:30
-
-
Save MattPorto/6091037c6e7553334eedbdef69e0960c to your computer and use it in GitHub Desktop.
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
# Faraday customs method: | |
class FaradayHttp | |
def with_openssl | |
system "openssl pkcs12 -in my-certificate-path -out certificate-output-path -nodes -password pass:certificate-password" | |
def cert_object | |
OpenSSL::X509::Certificate.new File.read("certificate-output-path") | |
end | |
# create PKey | |
def key_object | |
OpenSSL::PKey.read File.read("certificate-output-path") | |
end | |
faraday = Faraday::Connection.new 'https://example-site.com', | |
:ssl => { | |
certificate: cert_object, | |
private_key: key_object, | |
version: :SSLv3, | |
verify: false | |
} | |
faraday | |
end | |
end | |
# Controller that try to connect with the ssl server: | |
agent = FaradayHttp.new.with_openssl | |
page = agent.get '/login_path' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment