Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cert: Fix role certificate parameter #886

Merged
merged 2 commits into from
Nov 20, 2022

Conversation

colin-pm
Copy link
Member

The create_ca_certificate_role currently accepts a certificate parameter that can either be a PEM-formatted certificate or a path to a PEM-fromatted certificate file. The parameter is differentiated by trying to open a file with what's passed to certificate. For some systems, the lengh of a certificate is long enough that it will cause a OSError because of the path length.

The conditional was updated to actually inspect what is passed to contents. To avoid these issues moving forward, certificate will only accept a certificate string. Paths should be passed to the new certificate_file parameter. For now, passing a certificate file to certificate will generate a warning.

Signed-off-by: Colin McAllister colinmca242@gmail.com

Closes #841

@colin-pm colin-pm requested a review from a team as a code owner September 14, 2022 19:21
@colin-pm colin-pm added bug identity Identity secrets engine; identity management solution for Vault labels Sep 14, 2022
@colin-pm colin-pm added this to the 1.0.0 milestone Sep 14, 2022
@colin-pm colin-pm force-pushed the bugfix/auth_cert_checking branch from b7cc8f0 to d283c81 Compare September 14, 2022 19:25
@codecov
Copy link

codecov bot commented Sep 14, 2022

Codecov Report

Merging #886 (67b8f8e) into develop (5c91597) will decrease coverage by 1.98%.
The diff coverage is 92.30%.

@@             Coverage Diff             @@
##           develop     #886      +/-   ##
===========================================
- Coverage    82.93%   80.95%   -1.99%     
===========================================
  Files           59       59              
  Lines         2748     2772      +24     
===========================================
- Hits          2279     2244      -35     
- Misses         469      528      +59     
Impacted Files Coverage Δ
hvac/api/auth_methods/cert.py 91.04% <92.30%> (+1.21%) ⬆️
hvac/api/secrets_engines/transform.py 29.68% <0.00%> (-42.97%) ⬇️
hvac/api/system_backend/namespace.py 50.00% <0.00%> (-33.34%) ⬇️
hvac/api/auth_methods/mfa.py 100.00% <0.00%> (ø)
hvac/api/secrets_engines/kv.py 100.00% <0.00%> (ø)
hvac/api/secrets_engines/identity.py 94.00% <0.00%> (+0.02%) ⬆️
hvac/utils.py 77.27% <0.00%> (+0.20%) ⬆️
hvac/adapters.py 86.86% <0.00%> (+0.27%) ⬆️
hvac/api/vault_api_category.py 95.12% <0.00%> (+0.67%) ⬆️

@colin-pm colin-pm force-pushed the bugfix/auth_cert_checking branch from d283c81 to 50a541e Compare September 14, 2022 19:29
Copy link
Contributor

@briantist briantist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few questions:

  • Have we decided in which version certificate will stop accepting files altogether?
  • Can we report that version in the warning?
  • Are we tracking that in GitHub anywhere? (we could create an issue for removing it, assign it to a v2.0.0 milestone for example)
  • I don't see tests updated, are we missing tests for this method currently?

@colin-pm
Copy link
Member Author

Just a few questions:

  • Have we decided in which version certificate will stop accepting files altogether?

Let's do v2.0.0

  • Can we report that version in the warning?

I did add documentation in the API, which will propagate into the docs. Should we also add the version support will be removed in the warning message?

  • Are we tracking that in GitHub anywhere? (we could create an issue for removing it, assign it to a v2.0.0 milestone for example)

Created #914!

  • I don't see tests updated, are we missing tests for this method currently?

Just added tests 😄, forgot about doing that when I initially created this PR.

@briantist
Copy link
Contributor

I did add documentation in the API, which will propagate into the docs. Should we also add the version support will be removed in the warning message?

imo, yes, it's helpful to see in output, we could also add a link to #914 maybe?

  • Are we tracking that in GitHub anywhere? (we could create an issue for removing it, assign it to a v2.0.0 milestone for example)

Created #914!

Thanks! I updated the title and pinned the issue to make it more visible (maybe we can come up with a different way of surfacing upcoming breaking changes but should be ok for now).

@colin-pm colin-pm force-pushed the bugfix/auth_cert_checking branch 2 times, most recently from 80f6311 to 0980b3a Compare November 19, 2022 19:51
The `create_ca_certificate_role` currently accepts a `certificate` parameter that can either be a PEM-formatted certificate or a path to a PEM-fromatted certificate file. The parameter is differentiated by trying to open a file with what's passed to `certificate`. For some systems, the lengh of a certificate is long enough that it will cause a OSError because of the path length.

The conditional was updated to actually inspect what is passed to contents. To avoid these issues moving forward, `certificate` will only accept a certificate string. Paths should be passed to the new `certificate_file` parameter. For now, passing a certificate file to `certificate` will generate a warning.

Updated tests to use a RSA 4096 key as the certificate file's length would cause the OSError regression solved by this fix. Tests additionally test the certificate and certificate_file parameters.

Signed-off-by: Colin McAllister <colinmca242@gmail.com>
@colin-pm colin-pm force-pushed the bugfix/auth_cert_checking branch from 0980b3a to ac82b14 Compare November 19, 2022 20:48
@colin-pm colin-pm merged commit dbe0c01 into hvac:develop Nov 20, 2022
@colin-pm colin-pm deleted the bugfix/auth_cert_checking branch November 20, 2022 14:06
sebglon pushed a commit to sebglon/hvac that referenced this pull request Jan 19, 2023
* Cert: Fix role certificate parameter

The `create_ca_certificate_role` currently accepts a `certificate` parameter that can either be a PEM-formatted certificate or a path to a PEM-fromatted certificate file. The parameter is differentiated by trying to open a file with what's passed to `certificate`. For some systems, the lengh of a certificate is long enough that it will cause a OSError because of the path length.

The conditional was updated to actually inspect what is passed to contents. To avoid these issues moving forward, `certificate` will only accept a certificate string. Paths should be passed to the new `certificate_file` parameter. For now, passing a certificate file to `certificate` will generate a warning.

Updated tests to use a RSA 4096 key as the certificate file's length would cause the OSError regression solved by this fix. Tests additionally test the certificate and certificate_file parameters.

Signed-off-by: Colin McAllister <colinmca242@gmail.com>

* Update hvac/api/auth_methods/cert.py

Signed-off-by: Colin McAllister <colinmca242@gmail.com>
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
briantist added a commit that referenced this pull request Mar 6, 2023
* Cert: Fix role certificate parameter

The `create_ca_certificate_role` currently accepts a `certificate` parameter that can either be a PEM-formatted certificate or a path to a PEM-fromatted certificate file. The parameter is differentiated by trying to open a file with what's passed to `certificate`. For some systems, the lengh of a certificate is long enough that it will cause a OSError because of the path length.

The conditional was updated to actually inspect what is passed to contents. To avoid these issues moving forward, `certificate` will only accept a certificate string. Paths should be passed to the new `certificate_file` parameter. For now, passing a certificate file to `certificate` will generate a warning.

Updated tests to use a RSA 4096 key as the certificate file's length would cause the OSError regression solved by this fix. Tests additionally test the certificate and certificate_file parameters.

Signed-off-by: Colin McAllister <colinmca242@gmail.com>

* Update hvac/api/auth_methods/cert.py

Signed-off-by: Colin McAllister <colinmca242@gmail.com>
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
briantist added a commit to briantist/hvac that referenced this pull request May 10, 2023
* Cert: Fix role certificate parameter

The `create_ca_certificate_role` currently accepts a `certificate` parameter that can either be a PEM-formatted certificate or a path to a PEM-fromatted certificate file. The parameter is differentiated by trying to open a file with what's passed to `certificate`. For some systems, the lengh of a certificate is long enough that it will cause a OSError because of the path length.

The conditional was updated to actually inspect what is passed to contents. To avoid these issues moving forward, `certificate` will only accept a certificate string. Paths should be passed to the new `certificate_file` parameter. For now, passing a certificate file to `certificate` will generate a warning.

Updated tests to use a RSA 4096 key as the certificate file's length would cause the OSError regression solved by this fix. Tests additionally test the certificate and certificate_file parameters.

Signed-off-by: Colin McAllister <colinmca242@gmail.com>

* Update hvac/api/auth_methods/cert.py

Signed-off-by: Colin McAllister <colinmca242@gmail.com>
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug identity Identity secrets engine; identity management solution for Vault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create_ca_certificate_role() fails with 'File name too long' on macOS
2 participants