Sync PR1715 back to master, with some small tweaks

Note that this is still broken. TLSv1 mode wont work unless the meterpreter(s) are modified to support it. Once that work is done we can re-examine 1715.