fixed password field in p12 container

This commit is contained in:
oleghasjanov 2025-03-04 13:11:34 +02:00
parent 36968f363e
commit d85b93b8f2
4 changed files with 120 additions and 36 deletions

View file

@ -56,17 +56,27 @@ class Certificate < ApplicationRecord
return nil if private_key.blank?
decoded_key = Base64.decode64(private_key)
OpenSSL::PKey::RSA.new(decoded_key, Certificates::CertificateGenerator::CA_PASSWORD)
OpenSSL::PKey::RSA.new(decoded_key, Certificates::CertificateGenerator.ca_password)
rescue OpenSSL::PKey::RSAError
nil
end
# def parsed_p12
# return nil if p12.blank?
# decoded_p12 = Base64.decode64(p12)
# OpenSSL::PKCS12.new(decoded_p12)
# rescue OpenSSL::PKCS12::PKCS12Error
# nil
# end
def parsed_p12
return nil if p12.blank?
decoded_p12 = Base64.decode64(p12)
OpenSSL::PKCS12.new(decoded_p12)
rescue OpenSSL::PKCS12::PKCS12Error
OpenSSL::PKCS12.new(decoded_p12, '123456')
rescue OpenSSL::PKCS12::PKCS12Error => e
Rails.logger.error("Ошибка разбора PKCS12: #{e.message}")
nil
end