mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Calculate md5 differently
This commit is contained in:
parent
ead97b8382
commit
fecb6b40fc
3 changed files with 9 additions and 7 deletions
|
@ -44,9 +44,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @depp_user.pki
|
if @depp_user.pki
|
||||||
logger.error Digest::MD5.hexdigest(request.env['HTTP_SSL_CLIENT_CERT'])
|
unless @api_user.registrar_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
||||||
logger.error @api_user.certificates.registrar.pluck(:md5)
|
|
||||||
unless @api_user.registrar_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'])
|
|
||||||
@depp_user.errors.add(:base, :invalid_cert)
|
@depp_user.errors.add(:base, :invalid_cert)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,8 +45,12 @@ class ApiUser < User
|
||||||
registrar.messages.queued
|
registrar.messages.queued
|
||||||
end
|
end
|
||||||
|
|
||||||
def registrar_pki_ok?(crt)
|
def registrar_pki_ok?(crt, cn)
|
||||||
certificates.registrar.exists?(crt: crt)
|
cert = OpenSSL::X509::Certificate.new(crt)
|
||||||
|
md5 = OpenSSL::Digest::MD5.new(cert.to_der).to_s
|
||||||
|
logger.error(md5)
|
||||||
|
logger.error(cn)
|
||||||
|
certificates.registrar.exists?(md5: md5, cn: cn)
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_pki_ok?(crt)
|
def api_pki_ok?(crt)
|
||||||
|
|
|
@ -38,13 +38,12 @@ class Certificate < ActiveRecord::Base
|
||||||
pc = parsed_crt.try(:subject).try(:to_s) || ''
|
pc = parsed_crt.try(:subject).try(:to_s) || ''
|
||||||
cn = pc.scan(/\/CN=(.+)/).flatten.first
|
cn = pc.scan(/\/CN=(.+)/).flatten.first
|
||||||
self.common_name = cn.split('/').first
|
self.common_name = cn.split('/').first
|
||||||
self.md5 = Digest::MD5.hexdigest(crt)
|
self.md5 = OpenSSL::Digest::MD5.new(parsed_crt.to_der).to_s
|
||||||
self.interface = API
|
self.interface = API
|
||||||
elsif csr
|
elsif csr
|
||||||
pc = parsed_csr.try(:subject).try(:to_s) || ''
|
pc = parsed_csr.try(:subject).try(:to_s) || ''
|
||||||
cn = pc.scan(/\/CN=(.+)/).flatten.first
|
cn = pc.scan(/\/CN=(.+)/).flatten.first
|
||||||
self.common_name = cn.split('/').first
|
self.common_name = cn.split('/').first
|
||||||
self.md5 = Digest::MD5.hexdigest(csr)
|
|
||||||
self.interface = REGISTRAR
|
self.interface = REGISTRAR
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -91,6 +90,7 @@ class Certificate < ActiveRecord::Base
|
||||||
if err.match(/Data Base Updated/)
|
if err.match(/Data Base Updated/)
|
||||||
crt_file.rewind
|
crt_file.rewind
|
||||||
self.crt = crt_file.read
|
self.crt = crt_file.read
|
||||||
|
self.md5 = OpenSSL::Digest::MD5.new(parsed_crt.to_der).to_s
|
||||||
save!
|
save!
|
||||||
else
|
else
|
||||||
logger.error('FAILED TO CREATE CLIENT CERTIFICATE')
|
logger.error('FAILED TO CREATE CLIENT CERTIFICATE')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue