Skip to content

Raise PKCS8NotSupportedException for PKCS#8 keys - #1246

Open
jchampio wants to merge 2 commits into
paramiko:mainfrom
jchampio:dev/pkcs8-exception
Open

jchampio wants to merge 2 commits into
paramiko:mainfrom
jchampio:dev/pkcs8-exception

Conversation

@jchampio

@jchampio jchampio commented Jun 26, 2018 •

Copy link
Copy Markdown

We have a need to bubble up a warning to end users if they happen to be using a PKCS#8 private key (e.g. because they're on a FIPS system). This patch allows Paramiko clients to differentiate between generic SSHExceptions and those raised because a PKCS#8 key is in use.

The new unit-test keys are PKCS#8-format copies of the existing test_rsa*.key files.

This was developed against the 1.18 patch line (which we're currently using with Python 2); I expect you'll want me to cherry-pick this to other branches if you like the patch, but I wasn't really sure which ones.

@jchampio

Copy link
Copy Markdown
Author

All checks have failed

Hmm, Python 2.6 isn't a fan of with self.assertRaises(). Any preferences on how that test should be written?

@ploxiln

ploxiln commented Jun 26, 2018

Copy link
Copy Markdown
Contributor

something like:

        self.assertRaises(PKCS8NotSupportedException,
            RSAKey.from_private_key_file, test_path('test_rsa.pkcs8.key')
        )

@bitprophet

bitprophet commented Jun 26, 2018 •

Copy link
Copy Markdown
Member

@jchampio I super appreciate you taking the time to think about which branch this ought to go against! Unfortunately I'm not sure 1.18 is appropriate, this feels more like a feature-level change to me (a hint at this is the need to use versionadded/versionchanged).

Complicating things further is that I'm not doing feature support on the 1.x lines anymore (they rely on now-insecure PyCrypto; plus managing dual feature-release families is more of a chore than straight bugfixes). Is there a reason you're on 1.18 instead of e.g. a lower 2.x (if you're concerned about stability)? The only thing that really changed in Paramiko 2.0 was swapping PyCrypto out for Cryptography, the public APIs are still the same.

So, all else equal, I feel like this could actually go against master and come out in Paramiko 2.5.


In terms of the actual feature under discussion, I think I'm +1 on it, papering over the "SSHException everywhere!" design I inherited when I took over has been a very long standing goal.

@jchampio

Copy link
Copy Markdown
Author

@ploxiln I'll give that a try, thanks!

[...] I'm not doing feature support on the 1.x lines anymore

@bitprophet Completely understood. We're on the 1.x line at the moment for much the same reason -- no major bumps to pieces of the software stack, if we can avoid them. Knowing that the APIs remained constant into 2.x should help push us towards our next upgrade, though.

So, all else equal, I feel like this could actually go against master and come out in Paramiko 2.5.

Sounds good. I will reroll this PR against master when I get a chance (probably tomorrow morning). Thanks!

jchampio and others added 2 commits June 28, 2018 08:33
This patch allows clients to differentiate between generic SSHExceptions
and those raised because a PKCS#8 key is in use, so they can bubble up a
helpful warning to the end user.

Co-authored-by: Tyler Ramer <[email protected]>
...to test the previous commit. The new keys are PKCS#8-format copies of
the existing test_rsa*.key files.
@jchampio
jchampio force-pushed the dev/pkcs8-exception branch from 5466f4c to f78e02f Compare June 28, 2018 15:46
@jchampio
jchampio changed the base branch from 1.18 to master June 28, 2018 15:46
@jchampio

Copy link
Copy Markdown
Author

@bitprophet Re-rolled. I'm not sure how to bump Travis after the base branch change...

@jchampio

jchampio commented Jul 6, 2018

Copy link
Copy Markdown
Author

@bitprophet Anything else I can help with on this PR?

@bitprophet bitprophet added this to the 2.5.0 milestone Jul 10, 2018
@bitprophet

Copy link
Copy Markdown
Member

@jchampio Nope, I just need the time to jump back over to Paramiko from my other related repos. Just made sure this went in the 2.5 milestone. Thanks!

@bitprophet bitprophet modified the milestones: p0, p1 Oct 16, 2018
@bskinn

bskinn commented Jul 25, 2023

Copy link
Copy Markdown
Contributor

Relevant to the key/auth work of #387, though somewhat outside it since this is about declaring a lack of support via exception, as opposed to implementing new machinery to handle supported auth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants