1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00
httparty/examples/peer_cert.rb
Alex Matchneer 24106eef27 Expose .connection on block param (#648)
This provides access to the connection object,
which in turn exposes properties like `.peer_cert`
for performing additional validation against
x509 certificates.

Closes #633, Follow-up to #634
2019-03-20 18:50:06 +04:00

9 lines
291 B
Ruby

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
peer_cert = nil
HTTParty.get("https://www.example.com") do |fragment|
peer_cert ||= fragment.connection.peer_cert
end
puts "The server's certificate expires #{peer_cert.not_after}"