Ssl – How to specify the SSL port with command line curl

curlportssl

I'm trying to test the SSL connection on one of my servers. The server is behind a load balancer (LB) so it's listening for SSL connections on the port 8090.

I have use the --resolve option to test when talking to the LB which listens on port 443.

curl --resolve 'myservice.com:443:1.1.1.1' 'https://myservice.com'

but when I do:

curl --resolve 'myservice.com:8090:2.2.2.2' 'https://myservice.com:8090'

curl simply ignores the port and goes with 443. Of-course, this causes the DNS cache to miss and I end-up using the public DNS IP…

* Added myservice.com:8090:2.2.2.2 to DNS cache
* About to connect() to myservice.com port 443 (#0)
*   Trying 3.3.3.3...
* Connected to myservice.com (3.3.3.3) port 443 (#0)

How can I force curl to use the port 8090 for an SSL connection?

Thanks.

Best Answer

Tested with curl 7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3, the --resolve header works as expected with https and a non-standard port specified in both places.