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

Question: How to verify server certificate? #591

Open
pramodtech opened this issue May 24, 2018 · 1 comment
Open

Question: How to verify server certificate? #591

pramodtech opened this issue May 24, 2018 · 1 comment

Comments

@pramodtech
Copy link

pramodtech commented May 24, 2018

I am newbie on SSL concept, I am trying to connect to API which have x509 mutual auth. I got client cert, client key and server cert. All are pem files. I got it working with client cert and key and with verify: false. Now next step is how to verify server cert also?

include HTTParty
 DEFAULT_HEADERS = {
   'Content-Type' => 'application/json'
 }.freeze
 base_uri ENV.fetch('SERVICE')
 pem "#{Base64.decode64(ENV.fetch('CLIENT_CERT'))}#{Base64.decode64(ENV.fetch('CLIENT_KEY'))}\n"

 def self.iframe_url(**payload)
   post(
     '/test/create',
     body: payload.to_json,
     headers: DEFAULT_HEADERS,
     verify: false
   )
 end
@pjmartorell
Copy link

pjmartorell commented Mar 30, 2019

pem "#{Base64.decode64(ENV.fetch('CLIENT_CERT'))}#{Base64.decode64(ENV.fetch('CLIENT_KEY'))}\n" seems not to be correct. Contents should be in Base 64 format I think.

verify: false does not verify certificates, so it shouldn't be false.

Check the following web page, specifically the example "SSL/HTTPS request with PEM certificate". I suggest to first implement it in Net::HTTP to test everything is correct and then move it to HTTParty:

http://www.rubyinside.com/nethttp-cheat-sheet-2940.html

Give more details about the errors you get, otherwise is difficult to know what's the problem.

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

No branches or pull requests

2 participants