Skip to content

Make SSL_get_ciphers() results const in Modules/_ssl.c #162141

Open

Description

@chlily1

Bug report

Modules/_ssl.c stores results from SSL_get_ciphers() in non-const STACK_OF(SSL_CIPHER) * variables in two places:

  • server_ciphers in _ssl__SSLSocket_shared_ciphers_impl (*)
  • sk in _ssl__SSLContext_get_ciphers_impl

Both variables should be const: they are not modified, and are only read via sk_SSL_CIPHER_num() / sk_SSL_CIPHER_value(), which already take a const stack in OpenSSL and AWS-LC, so declaring them const is a no-op for existing builds.

(*) The client_ciphers variable immediately below this has to stay non-const for now, because OpenSSL's sk_SSL_CIPHER_find() still takes a non-const stack (openssl/openssl#33707).

Motivation: Though BoringSSL is not supported per PEP 644, this const-correctness change would be aligned with BoringSSL's planned changes to SSL_get_ciphers() and SSL_CTX_get_ciphers() to return const STACK_OF(SSL_CIPHER) * (see https://crbug.com/550501994).

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions