fix overriding port in case of ssl

I've found this problem isong https connection on port different from 443.
I think that this could fix the issue