FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-31432: Clarify CERT_NONE/OPTIONAL/REQUIRED doc by tiran · Pull Request #3530 · python/cpython · GitHub

Repository navigation

bpo-31432: Clarify CERT_NONE/OPTIONAL/REQUIRED doc - #3530

Merged
ned-deily merged 2 commits into
python:masterfrom
tiran:bpo-31432-cert-doc
Jun 11, 2018
Merged

ned-deily merged 2 commits into
python:masterfrom
tiran:bpo-31432-cert-doc

Conversation

tiran commented Sep 13, 2017 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.

Also discourage people from using CERT_OPTIONAL in client mode.

Signed-off-by: Christian Heimes christian@python.org

https://bugs.python.org/issue31432

tiran commented Sep 13, 2017

Copy link
Copy Markdown
Member Author

Memo to me: drop PROTOCOL_TLS_CLIENT in 2.7 backport.

tiran force-pushed the bpo-31432-cert-doc branch from 58d89be to 0243bd5 Compare September 15, 2017 15:08
Comment thread Modules/_ssl.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

nit: should be an SSLContext

tiran force-pushed the bpo-31432-cert-doc branch from 0243bd5 to 2f4126a Compare September 15, 2017 15:17
tiran force-pushed the bpo-31432-cert-doc branch 2 times, most recently from 597b493 to 0f3916d Compare January 20, 2018 23:14
tiran force-pushed the bpo-31432-cert-doc branch from 0f3916d to 6dde39e Compare February 22, 2018 17:40
tiran requested a review from vadmium February 22, 2018 17:40

tiran commented Feb 22, 2018

Copy link
Copy Markdown
Member Author

@vadmium Martin, you have helped me with documentation of PR #5259. Could you check this documentation, too?

Comment thread Doc/library/ssl.rst Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What if “anonymous ciphers are enabled”, mentioned under https://docs.python.org/dev/library/ssl.html#verifying-certificates?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'd rather not explain anonymous cipher suites and just remove them from the documentation completely. Anonymous cipher suites is a misleading term. They don't provide anonymity for the user but allow the server to stay anonymous by not providing any authentication. It's totally insecure and no longer supported in TLS 1.3 for a very good reason.

Comment thread Doc/library/ssl.rst Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What does cert_reqs default to if I call wrap_socket(..., ssl_version=PROTOCOL_TLS_CLIENT)? Judging by the signature and documentation for wrap_socket, CERT_NONE seems to be the default regardless of the protocol setting. If you are only talking about the default value for verify_mode after an SSLContext is constructed, I suggest to mention that under the entry for SSLContext.verify_mode, or the SSLContext constructor, instead of here. (Otherwise, maybe adjust the description of the top-level wrap_socket function.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

For a moment I feared that you have discovered a security bug.

Thankfully the code is robust and doesn't allow you to use PROTOCOL_TLS_CLIENT with default arguments of wrap_socket and SSLSocket. Both ssl.wrap_socket(ssl_version=ssl.PROTOCOL_TLS_CLIENT) and ssl.SSLSocket(ssl_version=ssl.PROTOCOL_TLS_CLIENT) will both fail with error Cannot set verify_mode to CERT_NONE when check_hostname is enabled..

So the insecure default doesn't work here. I consider it a feature. :) I'm going to deprecate ssl.wrap_socket and ssl.SSLSocket() default constructor because they have more fundamental issues.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Okay, now I realize that the PROTOCOL_TLS_CLIENT mode is newer than the old wrap_socket function. It was not clear that wrap_socket doesn’t support this new mode, but that is separate to what you are trying to do here.

tiran force-pushed the bpo-31432-cert-doc branch from 6dde39e to 7cb02cf Compare February 25, 2018 09:15

tiran commented Feb 25, 2018

Copy link
Copy Markdown
Member Author

@vadmium I have removed the misleading note about anonymous ciphers.

tiran force-pushed the bpo-31432-cert-doc branch from 7cb02cf to 350506a Compare May 14, 2018 18:07

Copy link
Copy Markdown
Contributor

Hi @vadmium, It looks like this is ready to be merged. Is there anything that prevents doing so at this point? Thanks.

tiran added 2 commits May 22, 2018 12:53
The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.

Also discourage people from using CERT_OPTIONAL in client mode.

Signed-off-by: Christian Heimes <christian@python.org>
The documentation no longer mentions anonymous ciphers. They are totally
insecure and irrelevant for virtually all users. The documentation was
also wrong. For anonymous ciphers, CERT_NONE, CERT_OPTIONAL and
CERT_REQUIRED all behaved the same.

Internally, CERT_REQUIRED = SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT
but the last flag is ignored in client mode. When a anonymous cipher is
used, clients ignore missing server certs.

Signed-off-by: Christian Heimes <christian@python.org>
tiran force-pushed the bpo-31432-cert-doc branch from 350506a to 86aa7d2 Compare May 22, 2018 10:53

Copy link
Copy Markdown
Member

@tiran, @vadmium I would prefer to merge this for 3.7.0. If I don't hear any objections in the next day or so, I will merge it.

ned-deily merged commit ef24b6c into python:master Jun 11, 2018

Copy link
Copy Markdown
Contributor

Thanks @tiran for the PR, and @ned-deily for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7.
🐍🍒⛏🤖

Copy link
Copy Markdown

GH-7649 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 11, 2018
The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.
Also discourage people from using CERT_OPTIONAL in client mode.
(cherry picked from commit ef24b6c)

Co-authored-by: Christian Heimes <christian@python.org>

Copy link
Copy Markdown
Contributor

Sorry, @tiran and @ned-deily, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ef24b6c54d40e7820456873a6eab6ef57d2bd0db 3.6

Copy link
Copy Markdown
Contributor

Sorry, @tiran and @ned-deily, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker ef24b6c54d40e7820456873a6eab6ef57d2bd0db 2.7

ned-deily pushed a commit that referenced this pull request Jun 11, 2018
…H-7649)

The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.
Also discourage people from using CERT_OPTIONAL in client mode.
(cherry picked from commit ef24b6c)

Co-authored-by: Christian Heimes <christian@python.org>
ned-deily pushed a commit to ned-deily/cpython that referenced this pull request Jun 12, 2018
The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.
Also discourage people from using CERT_OPTIONAL in client mode.

Copy link
Copy Markdown

GH-7652 is a backport of this pull request to the 3.6 branch.

ned-deily added a commit that referenced this pull request Jun 12, 2018
…H-7652)

The documentation for CERT_NONE, CERT_OPTIONAL, and CERT_REQUIRED were
misleading and partly wrong. It fails to explain that OpenSSL behaves
differently in client and server mode. Also OpenSSL does validate the
cert chain everytime. With SSL_VERIFY_NONE a validation error is not
fatal in client mode and does not request a client cert in server mode.
Also discourage people from using CERT_OPTIONAL in client mode.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL