Project

General

Profile

Bug #9833

OpenSSL::X509::Certificate#inspect がわかりにくくなっている

Added by znz (Kazuhiro NISHIYAMA) over 5 years ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
openssl
Target version:
-
ruby -v:
2.0.0p195
[ruby-dev:48217]

Description

SSL/TLS の証明書の簡易的なチェックに OpenSSL::X509::Certificate#inspect を便利に使っていたのですが、最近の ruby だと subject などに内容が出なくなってわかりにくくなっているのですが、以前のように内容が出た方が良いと思うのですが、どうでしょうか。

% cat inspect_cert.rb
#!/usr/bin/env ruby
require 'openssl'
require 'socket'
host = ARGV.shift
port = ARGV.shift.to_i
sock = TCPSocket.open(host, port)
ssl = OpenSSL::SSL::SSLSocket.new(sock)
ssl.connect
p ssl.peer_cert
% ruby1.9.1 -v inspect_cert.rb www.ruby-lang.org 443
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
#<OpenSSL::X509::Certificate subject=/OU=Domain Control Validated/CN=*.ruby-lang.org, issuer=/C=BE/O=GlobalSign nv-sa/CN=GlobalSign Domain Validation CA - SHA256 - G2, serial=1492412345881966875081918063955459968936780, not_before=2014-04-12 01:22:02 UTC, not_after=2014-08-25 05:22:02 UTC>
% ruby -v inspect_cert.rb www.ruby-lang.org 443
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
#<OpenSSL::X509::Certificate subject=#<OpenSSL::X509::Name:0x007f9b7960b230>, issuer=#<OpenSSL::X509::Name:0x007f9b7960b1b8>, serial=#<OpenSSL::BN:0x007f9b7960b140>, not_before=2014-04-12 01:22:02 UTC, not_after=2014-08-25 05:22:02 UTC>

History

#1

Updated by zzak (Zachary Scott) about 4 years ago

  • Assignee set to openssl

Updated by jeremyevans0 (Jeremy Evans) 2 months ago

  • Status changed from Open to Closed

This was fixed between Ruby 2.4 and 2.5:

$ ruby24 t/t.rb www.ruby-lang.org 443 
#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name:0x000005eb8490b120>, issuer=#<OpenSSL::X509::Name:0x000005eb8490b058>, serial=#<OpenSSL::BN:0x000005eb96082f50>, not_before=2019-07-24 00:10:47 UTC, not_after=2020-07-24 00:10:47 UTC>

$ ruby25 t/t.rb www.ruby-lang.org 443 
#<OpenSSL::X509::Certificate: subject=#<OpenSSL::X509::Name CN=m.ssl.fastly.net,O=Fastly\, Inc.,L=San Francisco,ST=California,C=US>, issuer=#<OpenSSL::X509::Name CN=GlobalSign CloudSSL CA - SHA256 - G3,O=GlobalSign nv-sa,C=BE>, serial=#<OpenSSL::BN:0x00000687d31a87e8>, not_before=2019-07-24 00:10:47 UTC, not_after=2020-07-24 00:10:47 UTC>

Also available in: Atom PDF