summaryrefslogtreecommitdiff
path: root/Modules/_ssl.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2017-09-05 21:55:40 -0700
committerGitHub <noreply@github.com>2017-09-05 21:55:40 -0700
commit6877111648ac3e042ee5d0458cbeb65dd1a84b2d (patch)
treec1e843cdc84d478c6ae396e892c274392e84c95e /Modules/_ssl.c
parent3463ee3972e0d14351ee18bce60ecfbf7ac96772 (diff)
downloadcpython-git-6877111648ac3e042ee5d0458cbeb65dd1a84b2d.tar.gz
bpo-29781: Fix SSLObject.version before handshake (#3364)
SSLObject.version() now correctly returns None when handshake over BIO has not been performed yet. Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Modules/_ssl.c')
-rw-r--r--Modules/_ssl.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index b001bca99d..2fa6bd28cd 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -1706,6 +1706,10 @@ _ssl__SSLSocket_version_impl(PySSLSocket *self)
if (self->ssl == NULL)
Py_RETURN_NONE;
+ if (!SSL_is_init_finished(self->ssl)) {
+ /* handshake not finished */
+ Py_RETURN_NONE;
+ }
version = SSL_get_version(self->ssl);
if (!strcmp(version, "unknown"))
Py_RETURN_NONE;