fix: Choose proper PEM vs DER format of private key instead of always using PEM format - #508
Merged
Merged
Conversation
joshua-janicas
force-pushed
the
fix/issue-427
branch
from
June 25, 2026 19:23
0e23d0f to
7148aa3
Compare
Make debug instead of info Remove comment
edgarrmondragon
force-pushed
the
fix/issue-427
branch
from
July 15, 2026 00:00
7148aa3 to
77d3b0f
Compare
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
edgarrmondragon
approved these changes
Jul 15, 2026
Member
|
Thanks @joshua-janicas ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #427.
Issue
Right now when I try to run a
meltano runcommand with my private key in a PEM format, i get the warning:However, when i remove the first and last line (BEGIN/END) for the formatting and put it all one one line, I get an error which ends in a stacktrace as such
I then tried to encode it as a base64 var, taking my private key, processing it via
then importing that output into my env var.
Funnily enough, that then worked for meltano's normal tap/target, but broke the dbt-snowflake connection
The only solution at this juncture was to have it as two separate env vars since the dbt-snowflake didn't like the b64 encoding. Which I thought was kind of silly.
What I changed
I then looked into the connector.py and noticed that in all 3 sections of the python function
get_private_keythat no matter what it was always serializing it as if it was a PEM format. So instead now it treats it as a DER format in the finalelsecondition at first, before falling back to PEM. The other two conditions that are checked beforehand still rely on PEM.For now the deprecation warnings are in place in case the maintainer decides to go forward with it, but at least now we can put the private key on a single line as an env var and continue to read it in either full PEM format, removing the headers and leaving it as one big block, or b64 encoding the whole PEM file (though in that case it would still break with dbt).
Solution Review
I did the changes locally on my repo (where i went directly into the connector.py)

Then i ran one of my tap/target commands,
meltano run tap-mssql-static target-snowflakefollowed by a dbt command.
meltano invoke dbt-snowflake:run --select stg_core_db__programNormal PEM Format
Removed the PEM, Left as One Line
Converted the PEM into a full b64
Showing again that it works for meltano, but breaks for dbt (which it is its own separate issue).

Forced the PEM b64 into a bad value
I removed 4 characters from the PEM data I converted into b64, to see if it would error out properly, and it did.
