Commit graph

54 commits

Author SHA1 Message Date
oleghasjanov
ae96863b88 feat: Implement P12 certificate generation improvements
- Replace hardcoded P12 password with randomly generated one
- Add p12_password column to certificates table
- Update certificate serializer to include p12 password in response
- Remove deprecated certificate revocation logic
- Add tests for certificate revocation functionality
- Implement async P12 generation via Sidekiq job
- Add job uniqueness to prevent parallel certificate generation

Migration changes:
- Replace p12_password_digest with p12_password column
- Add safety measures for column removal
2025-04-16 11:47:52 +03:00
oleghasjanov
0ba69ea848 added interface handler 2025-04-16 11:47:52 +03:00
oleghasjanov
fe90d787c2 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.
2025-04-16 11:47:52 +03:00
oleghasjanov
0925fa4d4b feat: Implement new certificate generation service
- Refactor certificate generation into a dedicated service object
- Add Base64 encoding for p12 binary data storage
- Implement serial number generation and storage
- Remove deprecated certificate generation code
- Simplify certificate status checks
- Update certificate controller to use new generator
- Add proper password handling for p12 containers

The main changes include:
- Moving certificate generation logic to CertificateGenerator service
- Proper handling of binary data encoding
- Implementing serial number tracking for future CRL support
- Removing old certificate generation and validation code
- Simplifying the certificate lifecycle management

This commit provides a more maintainable and robust certificate
generation system while preparing for future CRL implementation.
2025-04-16 11:47:52 +03:00
oleghasjanov
d85b93b8f2 fixed password field in p12 container 2025-04-16 11:47:52 +03:00
oleghasjanov
c08c3878e0 fix: improve p12 container generation with proper certificate status
Fix p12 containers being incorrectly generated with revoked status
Add proper serial number generation based on current time
Improve CRL handling in certificate_revoked? method
Fix controller parameter naming from cert_params to p12_params
Add comprehensive tests for certificate status and CRL handling
Include diagnostic methods for troubleshooting CRL issues
This commit resolves the issue where certificates were incorrectly
considered revoked during p12 container generation due to missing
or improperly handled CRL files.
2025-04-16 11:47:52 +03:00
oleghasjanov
3b594cf30d fix tests 2025-04-16 11:47:52 +03:00
oleghasjanov
0fe20bd63b Fixed Certificate#update_crl test to properly verify CRL updater script call
The test for Certificate.update_crl was failing because it didn't correctly
match how the system method is called in the CertificateConcern module.
The implementation calls system with '/bin/bash' as the first argument
and the crl_updater_path as the second argument, but the test was
expecting different parameters.

- Simplified the test_update_crl_should_call_crl_updater_script test to
  directly verify the script path is used without trying to intercept
  the system call
- Added proper environment variable handling for crl_updater_path
- Ensured original method is restored after test execution
2025-04-16 11:47:52 +03:00
oleghasjanov
5355397025 feat: improve certificate download extensions
Update certificate download functionality to use appropriate file extensions:
- Use .p12 extension for PKCS#12 files
- Keep .pem extension for PEM-encoded files (CSR, CRT, private key)

This change ensures that downloaded certificate files have the correct extension based on their format, making it easier for users to identify and use the files correctly.
2025-04-16 11:47:52 +03:00
Sergei Tsoganov
e00213ef1c Fixed codeclimate issue 2023-06-28 16:20:28 +03:00
Sergei Tsoganov
a9ed98d994 Fixed codeclimate issue 2023-06-28 16:01:10 +03:00
Sergei Tsoganov
47b6a1b87a Added endpoints for creating and downloading api user certificates 2023-06-28 15:48:40 +03:00
Sergei Tsoganov
b558c80e83 Added user certificate REPP endpoint and mailer 2023-06-09 17:05:22 +03:00
Sergei Tsoganov
bf3d971d7c Refactor and updated api user serializer 2023-05-30 13:21:29 +03:00
olegphenomenon
ce15a708a0 change flags in openssl cert generator 2021-10-11 15:40:13 +03:00
dinsmol
2f81e856fc fixed certificate model style errors 2021-09-09 21:42:58 +03:00
dinsmol
788af6cc5f fixed codeclimate errors 2021-09-09 21:34:56 +03:00
dinsmol
e7e3278267 fixed codeclimate errors 2021-09-09 13:06:51 +03:00
dinsmol
f4e0084895 fixed codeclimate errors (partically) 2021-09-09 09:19:09 +03:00
georg
7d4fe1c64b whitespace 2020-09-04 13:30:57 +03:00
georg
718249971f tostdout 2020-09-04 13:28:49 +03:00
georg
00eca4df5e Branch Condition 2020-09-04 13:16:18 +03:00
Georg Kahest
630c8878d8 force usage of bash command with args 2020-09-01 13:46:12 +03:00
Georg Kahest
0e686c5af5 split crl updating and application code 2020-08-18 08:42:16 +03:00
Georg Kahest
71b5af5b70 run configured crlupdater 2020-08-18 05:16:26 +03:00
Karl Erik Õunapuu
36e036e231 Write metadata only on create 2020-05-12 21:27:54 +03:00
Karl Erik Õunapuu
c2f8589044 Verify that CN is present when uploading CSR/CRT 2020-05-12 12:28:43 +03:00
Karl Erik Õunapuu
0fa7fcc771 Check that certificate is not revoked 2020-05-05 13:53:11 +03:00
Artur Beljajev
fa52001be6 Upgrade to Rails 5.0
Closes #377
2019-11-15 15:26:33 +02:00
Maciej Szlosarczyk
240bcf7911
Revoke, and then delete a certificate
This functionality is manually tested. because of heavy reliance on
server configuration and bash commands.

Ruby OpenSSL library lacks a good way to manage revocation list
programatically, which would be the best option to work with. We might
still use command line tools in the end.
2018-09-18 17:49:12 +03:00
Maciej Szlosarczyk
82dbd3e8b8
Use match? instead of match for regex where MatchData is unused 2018-08-17 10:54:39 +03:00
Artur Beljajev
c44f3df7f5 Remove Rubocop inline directives 2018-06-07 19:17:16 +03:00
Priit Tark
029dd167f5 Turn off certificates test output 2015-07-21 16:02:53 +03:00
Martin Lensment
9fd38f161a Check webclient cert in EPP when connecting from local network #2765 2015-07-13 13:53:12 +03:00
Priit Tark
7530d6ecab Rubocop upgraded #2711 2015-06-26 18:19:36 +03:00
Martin Lensment
7b6a12a4cc Remove unneccessary sanitation #2687 2015-06-18 16:03:30 +03:00
Martin Lensment
0732f55d7c Sanitize cert before saving #2687 2015-06-17 16:41:36 +03:00
Martin Lensment
fecb6b40fc Calculate md5 differently 2015-05-22 16:19:24 +03:00
Martin Lensment
0aa5399265 Revert back to CSR / CRT upload 2015-05-22 13:42:40 +03:00
Martin Lensment
9ad66c0999 Add CN support to certificates 2015-05-21 17:06:21 +03:00
Martin Lensment
ae746be970 Fix rubocop 2015-05-19 17:29:42 +03:00
Martin Lensment
405bb0dfd4 Form for uploading CRT directly 2015-05-19 12:13:48 +03:00
Martin Lensment
dde9ee6333 Capture output 2015-05-19 10:42:38 +03:00
Martin Lensment
7d85f9be04 Remove redirect to dev/null 2015-05-19 10:25:20 +03:00
Martin Lensment
c3e95cfcba Add logging to CRL update 2015-05-19 10:03:28 +03:00
Martin Lensment
936c570e1f Add sudo and examples 2015-05-15 17:20:59 +03:00
Martin Lensment
fb94a97401 Update CRL scripts 2015-05-15 17:04:53 +03:00
Martin Lensment
4388be15d6 Better error on signing csr twice 2015-04-24 17:16:38 +03:00
Priit Tark
e1041da50f Converted to use Rails Time.zone only to honor app time zone 2015-04-06 13:48:36 +03:00
Priit Tark
0e3382f348 Added test debugger for test signing 2015-03-27 15:22:58 +02:00