toolbelt icon indicating copy to clipboard operation
toolbelt copied to clipboard

Using a PFX with requests

Open erikbern opened this issue 9 years ago • 6 comments

I put together this gist after spending about 3h trying to figure it out:

https://gist.github.com/erikbern/756b1d8df2d1487497d29b90e81f8068

Happy to merge it into requests-toolbelt if you think it's a good place for it.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/34285114-using-a-pfx-with-requests?utm_campaign=plugin&utm_content=tracker%2F418367&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F418367&utm_medium=issues&utm_source=github).

erikbern avatar May 16 '16 19:05 erikbern

Neat!

So I'm open to this, but I'm also acutely aware that in a version of requests that will hopefully be available in the very near future we'll make it possible to pass an SSLContext object directly to requests. That should avoid some of the pain here: you wouldn't need to round trip via a file.

So this is a convenient helper, but I'm not sure how long its utility will last.

Lukasa avatar May 16 '16 20:05 Lukasa

The real utility here is converting a pfx to a pem file – not the temporary file context manager.

Arguably there's nothing requests-specific about handling a pfx file, so I'm not sure if requests-toolbelt is the right place. Let me know what you think

erikbern avatar May 16 '16 20:05 erikbern

I'm open to this too. I will just have some opinions about how it's added so pieces of it can be more reusable for others (if that makes any sense).

We'll also want to make sure we only conditionally require PyOpenSSL.

sigmavirus24 avatar May 16 '16 20:05 sigmavirus24

I have an implementation of a TransportAdapter that allows the use of a PFX/P12 without converting to a .pem file that I would like to contribute. Is this the appropriate place to discuss that?

rashley-iqt avatar Nov 19 '18 15:11 rashley-iqt

@rashley-iqt a pull request might be a better place to discuss it but sure.

sigmavirus24 avatar Nov 19 '18 17:11 sigmavirus24

I'll happily submit a PR, I just wasn't sure If it was more appropriate in the toolbelt or in the main requests library.

rashley-iqt avatar Nov 19 '18 17:11 rashley-iqt