diff --git a/scripts/xmpp-info.nse b/scripts/xmpp-info.nse
index dc7e3d16e..6b4bc00a9 100644
--- a/scripts/xmpp-info.nse
+++ b/scripts/xmpp-info.nse
@@ -222,12 +222,19 @@ end
local connect_tls = function(s, xmlns, server_name)
local request = make_request(server_name, xmlns)
- request = request .. ""
s:send(request)
while true do
local tag = receive_tag(s)
if not tag then break end
log_tag(tag)
+ if (tag.name == "required" or tag.name == "starttls") and tag.finish then
+ request = ""
+ local status, err = s:send(request)
+ if ( not(status) ) then
+ return false
+ end
+ tag = receive_tag(s)
+ end
if tag.name == "proceed" and tag.finish then
local status, error = s:reconnect_ssl()
if status then return true end