mirror of
https://github.com/internetee/registry.git
synced 2025-08-05 09:21:43 +02:00
12 lines
331 B
Ruby
12 lines
331 B
Ruby
class UpdateCertsAddCnFromCsr < ActiveRecord::Migration
|
|
def change
|
|
Certificate.all.each do |x|
|
|
if x.crt.blank? && x.csr.present?
|
|
pc = x.parsed_csr.try(:subject).try(:to_s) || ''
|
|
cn = pc.scan(/\/CN=(.+)/).flatten.first
|
|
x.common_name = cn.split('/').first
|
|
end
|
|
x.save
|
|
end
|
|
end
|
|
end
|