Skip to content

ssl.pyi: fix ssl.Purpose definition in py3#3054

Merged
srittau merged 1 commit intopython:masterfrom
Hanaasagi:fix-ssl-purpose-in-py3
Jun 20, 2019
Merged

ssl.pyi: fix ssl.Purpose definition in py3#3054
srittau merged 1 commit intopython:masterfrom
Hanaasagi:fix-ssl-purpose-in-py3

Conversation

@Hanaasagi
Copy link
Contributor

resolves #2770

In 2.7, https://github.com/python/cpython/blob/2b578479b96aa3deeeb8bac313a02b5cf3cb1aff/Lib/ssl.py#L337-L342

class Purpose(_ASN1Object):
    """SSLContext purpose flags with X509v3 Extended Key Usage objects
    """

Purpose.SERVER_AUTH = Purpose('1.3.6.1.5.5.7.3.1')
Purpose.CLIENT_AUTH = Purpose('1.3.6.1.5.5.7.3.2')

In 3.4, https://github.com/python/cpython/blob/3101b7076270756f8be699358c69c5d15ea2cc48/Lib/ssl.py#L313-L317

class Purpose(_ASN1Object, _Enum):
    """SSLContext purpose flags with X509v3 Extended Key Usage objects
    """
    SERVER_AUTH = '1.3.6.1.5.5.7.3.1'
    CLIENT_AUTH = '1.3.6.1.5.5.7.3.2'

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, a few remarks.

class _ASN1Object(NamedTuple('_ASN1Object', [('nid', int), ('shortname', str), ('longname', str), ('oid', str)])): ...
class Purpose(_ASN1Object, enum.Enum):
SERVER_AUTH: Purpose
CLIENT_AUTH: Purpose
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use CLIENT_AUTH = ... for enums.

@Hanaasagi Hanaasagi force-pushed the fix-ssl-purpose-in-py3 branch from f414655 to a74e168 Compare June 20, 2019 07:09
@Hanaasagi
Copy link
Contributor Author

Fixed, thanks.

@srittau srittau merged commit 2b6a99c into python:master Jun 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ssl.Purpose.CLIENT_AUTH is incompatible with ssl.Purpose

2 participants