mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 14:36:22 +02:00
fix: improve certificate parsing and file extensions
- Fix PKCS12 container parsing by using consistent password - Add proper file extensions for certificate downloads (.key, .csr, .crt) - Improve private key parsing by removing unnecessary Base64 decoding - Add error logging for certificate parsing failures - Clean up certificate serializer code The main changes include: - Using P12_PASSWORD consistently across generation and parsing - Adding proper file extensions for different certificate types - Fixing private key parsing to handle PEM format correctly - Adding detailed error logging for debugging purposes - Removing redundant code comments and improving code clarity This commit improves the reliability of certificate handling and provides better user experience with correct file extensions.
This commit is contained in:
parent
0925fa4d4b
commit
fe90d787c2
4 changed files with 29 additions and 5 deletions
|
@ -9,8 +9,7 @@ module Serializers
|
|||
|
||||
def to_json(obj = certificate)
|
||||
json = obj.as_json.except('csr', 'crt', 'private_key', 'p12')
|
||||
|
||||
# Безопасно извлекаем данные из сертификатов
|
||||
|
||||
begin
|
||||
csr = obj.parsed_csr
|
||||
rescue StandardError => e
|
||||
|
@ -46,7 +45,6 @@ module Serializers
|
|||
json[:csr] = csr_data(csr) if csr
|
||||
json[:crt] = crt_data(crt) if crt
|
||||
|
||||
# Если в тестовой среде данные не удалось извлечь, добавляем заглушки
|
||||
if (Rails.env.test? || ENV['SKIP_CERTIFICATE_VALIDATIONS'] == 'true')
|
||||
if csr.nil? && obj.csr.present?
|
||||
json[:csr] = { version: 0, subject: obj.common_name || 'Test Subject', alg: 'sha256WithRSAEncryption' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue