2017-04-06 121 views
1

我有一個revoked.crl證書吊銷列表和一些條目。如何從中檢索序列號。當我使用撤銷方法時,它會返回條目數組,如 「#OpenSSL :: X509 ::撤銷:0x007f944b1fd0d8」。誰能告訴我如何解析這個來獲得確切的序列號?從CRL列表中獲取序列號

回答

0

嘗試類似:

require "openssl" 

crl_filepath = "./path/to/mylist.crl" 
puts "PARSING CRL FILE #{crl_filepath} ..." 

crl = OpenSSL::X509::CRL::new(File.read(crl_filepath)) 
puts "... ISSUER: #{crl.issuer.to_s}" 
puts "... VERSION: #{crl.version.to_s}" 
puts "... LAST UPDATE: #{crl.last_update.to_s}" 
puts "... NEXT UPDATE: #{crl.next_update.to_s}" 

puts "INVESTIGATING FIRST CERTIFICATE..." 
r = crl.revoked.first # FYI this is an OpenSSL::X509::Revoked object 
puts "... SERIAL: #{r.serial.to_s}" 
puts "... TIME: #{r.time.to_s}" 
puts "... EXTENSIONS (#{r.extensions.count}):" 
r.extensions.each do |ext| 
    puts " ... #{ext.to_h}" 
end 

相關文章: