api - HTTP Request with PEM cert -
here simple class request thru https webservice pem cert.
require [omit verbose] class api def initialize @ctx = openssl::ssl::context::client.new @ctx.private_key = "/home/xxxxxx/development.pem" @ctx.verify_mode = libssl::verifymode::none end def customers response = http::client.get "https://xxx.xxx.xxx.xxx:xxxx/api/customers", nil, nil, @ctx puts response.status_code puts response.body puts response.inspect nil end end api.new.customers but receive 401 authorization required crystal run src/api.cr.
you need set certificate_chain too.
add line in initialize method
@ctx.certificate_chain = "/home/xxxxxx/development.pem"
Comments
Post a Comment