Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSLContext.set_servername_callback should be able to set argument #61383

Closed
grooverdan mannequin opened this issue Feb 11, 2013 · 4 comments
Closed

SSLContext.set_servername_callback should be able to set argument #61383

grooverdan mannequin opened this issue Feb 11, 2013 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@grooverdan
Copy link
Mannequin

grooverdan mannequin commented Feb 11, 2013

BPO 17181
Nosy @pitrou, @tiran

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2021-10-21.22:22:29.565>
created_at = <Date 2013-02-11.10:07:38.897>
labels = ['type-feature', 'library']
title = 'SSLContext.set_servername_callback should be able to set\targument'
updated_at = <Date 2021-10-21.22:22:29.564>
user = 'https://bugs.python.org/grooverdan'

bugs.python.org fields:

activity = <Date 2021-10-21.22:22:29.564>
actor = 'christian.heimes'
assignee = 'none'
closed = True
closed_date = <Date 2021-10-21.22:22:29.565>
closer = 'christian.heimes'
components = ['Library (Lib)']
creation = <Date 2013-02-11.10:07:38.897>
creator = 'grooverdan'
dependencies = []
files = []
hgrepos = []
issue_num = 17181
keywords = []
message_count = 4.0
messages = ['181889', '181898', '181923', '404688']
nosy_count = 3.0
nosy_names = ['pitrou', 'christian.heimes', 'grooverdan']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue17181'
versions = ['Python 3.5']

@grooverdan
Copy link
Mannequin Author

grooverdan mannequin commented Feb 11, 2013

I think my original implementation of the SNI callback to see a original sslcontext was wrong. It would be much more useful for the SSLContext.set_servername_callback to take a callable and an object as an argument.

This would allow constructs like the following where self can be used within the callback. Example:

        def cb_sni(ssl_sock, server_name, self):
            self.sniname = server_name

        self.context.set_servername_callback(cb_sni, self)

The original functionality can still occur with:

        self.context.set_servername_callback(cb_sni, self.context)

Agree?

@grooverdan grooverdan mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Feb 11, 2013
@pitrou
Copy link
Member

pitrou commented Feb 11, 2013

This would allow constructs like the following where self can be used
within the callback. Example:

    def cb_sni(ssl_sock, server_name, self):
        self.sniname = server_name

    self.context.set_servername_callback(cb_sni, self)

The original functionality can still occur with:

    self.context.set_servername_callback(cb_sni, self.context)

But you could simply use a closure:

        def cb_sni(ssl_sock, server_name):
            self.sniname = server_name

        self.context.set_servername_callback(cb_sni)

@pitrou pitrou changed the title SSLContext.set_servername_callback should be able to set argument SSLContext.set_servername_callback should be able to set argument Feb 11, 2013
@pitrou
Copy link
Member

pitrou commented Feb 11, 2013

(functools.partial is another solution to the problem)

@tiran
Copy link
Member

tiran commented Oct 21, 2021

As Antoine said, you can use a partial function, closure, or an instance method as a callable.

Besides nobody else has requested an additional argument in the past eight years. I see this as a strong indication that an argument is not required.

@tiran tiran closed this as completed Oct 21, 2021
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants