mirror of
https://github.com/internetee/registry.git
synced 2025-08-03 16:32:04 +02:00
Add API pki cert check
This commit is contained in:
parent
fe19ac743b
commit
f590a107fb
2 changed files with 11 additions and 7 deletions
|
@ -54,8 +54,13 @@ class ApiUser < User
|
|||
certificates.registrar.exists?(md5: md5, common_name: cn)
|
||||
end
|
||||
|
||||
def api_pki_ok?(crt)
|
||||
certificates.api.exists?(crt: crt)
|
||||
def api_pki_ok?(crt, cn)
|
||||
crt = crt.split(' ').join("\n")
|
||||
crt.gsub!("-----BEGIN\nCERTIFICATE-----\n", "-----BEGIN CERTIFICATE-----\n")
|
||||
crt.gsub!("\n-----END\nCERTIFICATE-----", "\n-----END CERTIFICATE-----")
|
||||
cert = OpenSSL::X509::Certificate.new(crt)
|
||||
md5 = OpenSSL::Digest::MD5.new(cert.to_der).to_s
|
||||
certificates.api.exists?(md5: md5, common_name: cn)
|
||||
end
|
||||
|
||||
class << self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue