python / python/cpython

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

Aberta
#129,216 5 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

extension-modules topic-SSL type-feature
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece revisando o commit 7c3ddb5 e a discussão na issue 60691; em seguida, inspecione a implementação atual de SSLContext.load_cert_chain e seus testes. A alteração estará concluída quando objetos semelhantes a arquivos de certificado e chave que contenham strings incorporadas forem aceitos com o tratamento de senha existente, com cobertura para o uso proposto de BytesIO.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
security
Tipo de issue
Funcionalidade
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.