Take CN from CSRs as well

This commit is contained in:
Martin Lensment 2015-05-25 11:00:56 +03:00
parent 02cc84b761
commit d8ab710f10

View file

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