I am a newbie on SSL concept, I am trying to connect to API which has x509 mutual auth using HTTParty.
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?
HTTParty documentation link https://github.com/jnunemaker/httparty/tree/master/docs#working-with-ssl
class ServiceClient
include HTTParty
DEFAULT_HEADERS = {
'Content-Type' => 'application/json'
}.freeze
base_uri 'https://example.com'
pem File.read("#{File.expand_path('.')}/path/to/certs/cert.pem")
def self.iframe_url(**payload)
post(
'/test/create',
body: payload.to_json,
headers: DEFAULT_HEADERS,
verify: false
)
end
end
Call to service client
payload = {user_id: "100", account_id: "1234"}
ServiceClient.iframe_url(payload)
Edit:
HTTParty is not a hard requirement so solution with any http client would work for me.
If I remove verify: false
I get below error.
OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed