mirror of
https://github.com/internetee/registry.git
synced 2025-07-21 10:16:01 +02:00
Take CN from CSRs as well
This commit is contained in:
parent
02cc84b761
commit
d8ab710f10
1 changed files with 12 additions and 0 deletions
12
db/migrate/20150525075550_update_certs_add_cn_from_csr.rb
Normal file
12
db/migrate/20150525075550_update_certs_add_cn_from_csr.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue