-
Notifications
You must be signed in to change notification settings - Fork 323
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
access ssl certificate details? #747
Comments
I don't believe so. Which type were you thinking of having an accessor for it? |
some way to access peer_cert? like this require 'openssl'
require 'net/http'
require 'uri'
url = ARGV[0] # get the URL from the command line arguments
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true # use SSL for the request
begin
http.start
rescue OpenSSL::SSL::SSLError => e
puts "Error: SSL connection could not be established. #{e.message}"
exit
end
cert = http.peer_cert
if cert.nil?
puts "Error: No SSL certificate could be retrieved."
exit
end
cert = OpenSSL::X509::Certificate.new(cert)
puts "Issuer: #{cert.issuer}"
puts "Common Names: #{cert.subject.to_a.select { |name, _, _| name == 'CN' }.map { |_, value, _| value }.join(', ')}"
puts "Valid From: #{cert.not_before}"
puts "Valid Until: #{cert.not_after}" example:
|
I think this should suffice: |
Seems like you could use an accessor like |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to access the certificate details from the response?
Interested in Common name, issued by and validity period.
The text was updated successfully, but these errors were encountered: