python / python/cpython

Support loading keys and certificates as variables (bytes) in particular in the load_cert_chain function

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

還沒有人認領這個 Issue。

type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Proposal:

In MutualTLS Authentication scenarios it's useful to maintain client credential (private_key) confidentiality by allowing loading of the credential from encrypted key archives for example PKCS12. Python Cryptography and other modules allow loading of private keys into memory and at present we need to write those sensitive files to disk temporarily in order to load them into our TLS Client context.

This appears to be the existing code https://github.com/python/cpython/blob/a9c304cf020e2fa3ae78fd88359dfc808c9dd639/Modules/_ssl.c#L3899


    if (keyfile && !PyUnicode_FSConverter(keyfile, &keyfile_bytes)) {
        if (PyErr_ExceptionMatches(PyExc_TypeError)) {
            PyErr_SetString(PyExc_TypeError,
                            "keyfile should be a valid filesystem path");
        }
        goto error;
    }

Has this already been discussed elsewhere?

There is one somewhat similar feature request relating to loading from PKCS11 tokens. This is not related.

Links to previous discussion of this feature:

No response

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Modules/_ssl.c 中的 load_cert_chain 實作以及 issue 中所示的檔案系統路徑轉換開始。檢視目前的函式如何接受金鑰和憑證路徑,然後確定記憶體中字節輸入所需的 API 和測試涵蓋範圍。當憑證資料可以從字節載入而不需要暫存敏感檔案時,即表示完成。

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

評估

技術堆疊
c, python
領域
authentication, security
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

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

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