Skip to content

Remove redundant base64 encoding for private_key_base64 parameter. #2133

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dmitry-workato
Copy link

The PKCS 8 file already provides base64 encoded string of the private key, no need for extra base64 encode/decode. This slows dows the connection with the database.

This PR removes extra base64 decode/encode step, improving the peformance of private key parsing for "private_key_base64" parameter. Notice, that the parameter is still "spark" serializable as it is a java String.

Unfortunately not backward compatible. If accepted by the maintainers I would be happy to create a new property: "private_key_pkcs8_pem" to make this change backward compatible.

Overview

SNOW-XXXXX

Pre-review self checklist

  • PR branch is updated with all the changes from master branch
  • The code is correctly formatted (run mvn -P check-style validate)
  • New public API is not unnecessary exposed (run mvn verify and inspect target/japicmp/japicmp.html)
  • The pull request name is prefixed with SNOW-XXXX:
  • Code is in compliance with internal logging requirements

External contributors - please answer these questions before submitting a pull request. Thanks!

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

    Issue: #NNNN

  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 modifying authorization mechanisms
    • I am adding new credentials
    • I am modifying OCSP code
    • I am adding a new dependency or upgrading an existing one
    • I am adding new public/protected component not marked with @SnowflakeJdbcInternalApi (note that public/protected methods/fields in classes marked with this annotation are already internal)
  3. Please describe how your code solves the related issue.

    Please write a short description of how your code change solves the related issue.

The PKCS 8 file already provides base64 encoded string of the private
key, no need for extra base64 encode/decode. This slows dows the
connection with the database.

This PR removes extra base64 decode/encode step, improving the peformance
of private key parsing for "private_key_base64" parameter. Notice, that
the parameter is still "spark" serializable as it is a java String.

Unfortunately not backward compatible. If accepted by the maintainers
I would be happy to create a new property: "private_key_pkcs8_pem" to make
this change backward compatible.
@sfc-gh-snowflakedb-snyk-sa
Copy link
Contributor

sfc-gh-snowflakedb-snyk-sa commented Mar 31, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Copy link

github-actions bot commented Mar 31, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@dmitry-workato
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@dmitry-workato dmitry-workato marked this pull request as ready for review April 1, 2025 08:32
@dmitry-workato dmitry-workato requested a review from a team as a code owner April 1, 2025 08:32
@sfc-gh-wfateem
Copy link
Collaborator

@dmitry-workato Just so it's clear, how would you use the parameter after this change? Are you providing only the base64 encoded content of the private key as a string, or are you also including the header
-----BEGIN ENCRYPTED PRIVATE KEY----- and the footer -----END ENCRYPTED PRIVATE KEY-----

@dmitry-workato
Copy link
Author

@dmitry-workato Just so it's clear, how would you use the parameter after this change? Are you providing only the base64 encoded content of the private key as a string, or are you also including the header -----BEGIN ENCRYPTED PRIVATE KEY----- and the footer -----END ENCRYPTED PRIVATE KEY-----

Hey @sfc-gh-wfateem, the header/footer still would be part of the key. Would it work for all the cases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants