This commit is contained in:
Martin Lensment 2015-05-25 11:04:53 +03:00
parent d8ab710f10
commit f6c7dd48db

View file

@ -2,7 +2,7 @@ class UpdateCertsAddCnFromCsr < ActiveRecord::Migration
def change def change
Certificate.all.each do |x| Certificate.all.each do |x|
if x.crt.blank? && x.csr.present? if x.crt.blank? && x.csr.present?
pc = x.parsed_crt.try(:subject).try(:to_s) || '' pc = x.parsed_csr.try(:subject).try(:to_s) || ''
cn = pc.scan(/\/CN=(.+)/).flatten.first cn = pc.scan(/\/CN=(.+)/).flatten.first
x.common_name = cn.split('/').first x.common_name = cn.split('/').first
end end