Commit f2e13d55 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

ganeti.http: Explicitly initiate handshake

Otherwise it would be done on the first read/write operation, making
error handling more difficult (such as EOF during handshake).

Reviewed-by: iustinp
parent d7fa9982
......@@ -264,6 +264,14 @@ class HttpClientRequestExecutor(http.HttpBase):
# keep-alive settings, see "man 7 tcp" for TCP_KEEPCNT, TCP_KEEPIDLE and
# TCP_KEEPINTVL.
# Do the secret SSL handshake
if self.using_ssl:
self.sock.set_connect_state()
try:
http.Handshake(self.poller, self.sock, self.WRITE_TIMEOUT)
except http.HttpSessionHandshakeUnexpectedEOF:
raise http.HttpError("Server closed connection during SSL handshake")
def _SendRequest(self):
"""Sends request to server.
......
......@@ -252,6 +252,15 @@ class _HttpServerRequestExecutor(object):
request_msg_reader = None
force_close = True
try:
# Do the secret SSL handshake
if self.server.using_ssl:
self.sock.set_accept_state()
try:
http.Handshake(self.poller, self.sock, self.WRITE_TIMEOUT)
except http.HttpSessionHandshakeUnexpectedEOF:
# Ignore rest
return
try:
try:
request_msg_reader = self._ReadRequest()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment