-
Notifications
You must be signed in to change notification settings - Fork 128
OCPBUGS-49769: Validate the key and cert content before accepting #669
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
base: master
Are you sure you want to change the base?
Conversation
This change enforces the validation that a private key does not contain any certificate/public key, and that a public key does not contain any private key. This is required because during the .pem file assembling for HAProxy, in case a certificate is present on the private key field, it will be ignored by the PEM sanitization function. This lack of validation can cause a situation where the .pem file of HAProxy will be created as private key -> CA chain -> leaf certificate, which is invalid and rejected by HAProxy. As the right order is private key -> leaf certificate -> CA Chain, and the proper ordering of the public key/CA certificate is already guaranteed by X509KeyPair(), we can reject the misusage of private keys or certificates on the wrong fields, that can cause HAProxy to stop Additionally, some tests were added to validate that PEM files exported from a P12 and that contain bag attributes like friendlyNames are valid and that the process of sanitization of these files will clean them correctly and process they rest of the certificates and private keys
@rikatz: This pull request references Jira Issue OCPBUGS-49769, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/jira refresh |
@rikatz: This pull request references Jira Issue OCPBUGS-49769, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/jira refresh |
@rikatz: This pull request references Jira Issue OCPBUGS-49769, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@rikatz: This pull request references Jira Issue OCPBUGS-49769, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/retest |
/hold I will try to write some e2e test for these cases as well, + some unit tests on different sets as per discussed with @Miciah |
/assign |
/assign @alebedev87 @candita @Thealisyed |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
@rikatz: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This change enforces the validation that a private key does not contain any certificate/public key, and that a public key does not contain any private key.
This is required because during the .pem file assembling for HAProxy, in case a certificate is present on the private key field, it will be ignored by the PEM sanitization function.
This lack of validation can cause a situation where the .pem file of HAProxy will be created as private key -> CA chain -> leaf certificate, which is invalid and rejected by HAProxy.
As the right order is private key -> leaf certificate -> CA Chain, and the proper ordering of the public key/CA certificate is already guaranteed by X509KeyPair(), we can reject the misusage of private keys or certificates on the wrong fields, that can cause HAProxy to stop
Additionally, some tests were added to validate that PEM files exported from a P12 and that contain bag attributes like friendlyNames are valid and that the process of sanitization of these files will clean them correctly and process they rest of the certificates and private keys.
As an example, the lack of validation would cause the following invalid PEM file to be added to HAProxy and make it get stuck on reconfiguration:
EDIT: test executed: