Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup SSL documentation #1133

Open
casiodk opened this issue Feb 28, 2020 · 2 comments
Open

Setup SSL documentation #1133

casiodk opened this issue Feb 28, 2020 · 2 comments

Comments

@casiodk
Copy link

casiodk commented Feb 28, 2020

Hi guys

Thanks for an awesome gem.

I was trying to setup an ssl connection with a certificate and a private key, but i thought it was very hard to find any documentation on how to do this.

I finally found this post on slack overflow, which seems to do the trick.

https://stackoverflow.com/questions/18886501/http-library-for-ruby-with-https-ssl-client-certificate-and-keep-alive-support#answer-18887425

Maybe an idea could be to add this to the documentation ?

@casiodk
Copy link
Author

casiodk commented Feb 28, 2020

def connection
          Faraday.new(url: BASE_URL, ssl: ssl_options) do |f|
            f.adapter :net_http_persistent, pool_size: 5 do |http|
              # yields Net::HTTP::Persistent
              http.idle_timeout = 100
              http.retry_change_requests = true
            end
          end
        end

        def ssl_options
          {
            client_cert: OpenSSL::X509::Certificate.new(File.read(CERTIFICATE_PATH)),
            client_key:  OpenSSL::PKey::RSA.new(File.read(PRIVATE_KEY_PATH), ""),
            verify: false
          }
        end

@iMacTia
Copy link
Member

iMacTia commented Mar 9, 2020

Hi @casiodk, that's a fair point, we don't talk about SSL options on our website, but that's not the only option we don't cover at the moment.
The main reason for that, is that these options are different for each adapter, so the example you posted above only works with the Net::HTTP, and will be different for the others.

A good solution might be of adding all the available options (e.g. ssl_options) for each adapter in the corresponding adapter page. For Net::HTTP that would have been https://lostisland.github.io/faraday/adapters/net-http

Would something like that make sense? It will just take some time to go through the code and add them, but it's definitely something we can look at

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants