python / python/cpython

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

未關閉
#129,216 5 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

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. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先查看 commit 7c3ddb5 和 issue 60691 中的討論,然後檢查目前的 SSLContext.load_cert_chain 實作及其測試。當包含嵌入字串的憑證和金鑰類檔案物件能以現有的密碼處理方式被接受,並且為提議的 BytesIO 用法加入覆蓋率時,此變更即完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
security
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。