python / python/cpython

Allow to load SSL certfile and keyfile from a file-like object

オープン
#129,216 コメント 5 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

extension-modules topic-SSL type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Feature or enhancement

Proposal:
# Have a look in commit 7c3ddb5
# It should be possible to also load certfile and keyfile from embedded certificate strings
cert_file = io.BytesIO(SERVER_CERT_STRING.encode('utf-8'))
key_file = io.BytesIO(SERVER_KEY_ENCRYPTED_STRING.encode('utf-8'))
context.load_cert_chain(certfile=cert_file, keyfile=key_file, password=key_pass)

https://github.com/python/cpython/commit/7c3ddb51b969fbfc022c8b6a5d1c1a3c6861d481

It should be possible to also load certfile and keyfile from embedded certificate strings. At the moment the code only reads the certificates from files (filepath). But when you don't want to have the saved/written certificates on the storage you should be able to load them from embedded strings.

Would it possible to include this code to the latest cpython? I tested this code from commit 7c3ddb5 with cpython v3.8.10 and here it almost has worked directly and only few lines had to be adapted. But I also tried it with the latest cpython version and here in Visual Studio there are some warnings. I don't know why this functionality isn't included in the master branch because it adds useful and advanced functionalities.

Has this already been discussed elsewhere?

https://github.com/python/cpython/issues/60691

Links to previous discussion of this feature:

https://github.com/python/cpython/compare/main...jgehrcke:cpython:jgehrcke/address-issue-16487-sept17

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まずコミット 7c3ddb5 と issue 60691 の議論を確認し、その後、現在の SSLContext.load_cert_chain の実装とそのテストを調査してください。証明書および鍵のファイルライクオブジェクトに埋め込まれた文字列が含まれている場合、それらが既存のパスワード処理で受け入れられ、提案された BytesIO の使用に対するカバレッジが追加されれば、変更は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
security
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。