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

SNOW-1820480 making OCSP validation code more resillient #2107

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

sfc-gh-mkeller
Copy link
Collaborator

Please answer these questions before submitting your pull requests. Thanks!

  1. What GitHub issue is this PR addressing? Make sure that there is an accompanying issue to your PR.

    Fixes SNOW-1774037: OCSP check fails when execption is not of type RevocationCheckError #2094

  2. Fill out the following pre-review checklist:

    • I am adding a new automated test(s) to verify correctness of my new code
    • I am adding new logging messages
    • I am adding a new telemetry message
    • I am modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency
  3. Please describe how your code solves the related issue.

    I try to make the code that calls into cryptography more resilient against TypeErrors.

  4. (Optional) PR for stored-proc connector:

@sfc-gh-mkeller
Copy link
Collaborator Author

One user who was encountering this issue has tested this fix

@sfc-gh-mkeller sfc-gh-mkeller self-assigned this Nov 25, 2024
@sfc-gh-mkeller sfc-gh-mkeller marked this pull request as ready for review November 25, 2024 18:37
@sfc-gh-mkeller sfc-gh-mkeller added the DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector label Nov 25, 2024
Copy link
Contributor

@sfc-gh-wshangguan sfc-gh-wshangguan left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +375 to +384
additional_kwargs: dict[str, typing.Any] = dict()
if isinstance(public_key, RSAPublicKey):
additional_kwargs["padding"] = padding.PKCS1v15()
additional_kwargs["algorithm"] = utils.Prehashed(chosen_hash)
elif isinstance(public_key, DSAPublicKey):
additional_kwargs["algorithm"] = utils.Prehashed(chosen_hash)
elif isinstance(public_key, EllipticCurvePublicKey):
additional_kwargs["signature_algorithm"] = ECDSA(
utils.Prehashed(chosen_hash)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This fix covers more than the issue reported by the user?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, only the reported issue. TypeError is raised in the case where we send in too many arguments to the verify() call.

@@ -11,6 +11,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
- v3.12.4(TBD)

Choose a reason for hiding this comment

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

Should this still be TBD?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Unless you can tell me when the next release is happening yes

Choose a reason for hiding this comment

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

🧞

Copy link

@sfc-gh-fhe sfc-gh-fhe left a comment

Choose a reason for hiding this comment

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

LGTM

@sfc-gh-mkeller sfc-gh-mkeller merged commit 557774d into main Nov 25, 2024
95 of 96 checks passed
@sfc-gh-mkeller sfc-gh-mkeller deleted the mkeller/SNOW-1820480/OCSP-verification-arguments branch November 25, 2024 21:30
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DO_NOT_PORT_CHANGES_TO_SP Add this label when changes in this PR do not need to be port to SP connector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SNOW-1774037: OCSP check fails when execption is not of type RevocationCheckError
3 participants