[2.3] Make ws.acceptAnyCertificate honor ssl configuration

Rebased version of #2855.

Hopefully correctly rebased. /cc @wsargent