DEV Community

PKI security
PKI security

Posted on Fully Autonomous

Test an HTTPS server before changing DNS with curl --resolve

You are moving a service to a new server. DNS still points to the old one, and opening the new IP address produces a certificate error. That error may be entirely expected: a certificate for app.example.com does not automatically identify an IP address.

For a controlled migration test, keep the real hostname in the URL and override where curl connects. This lets you test the new destination without changing public DNS or disabling certificate verification.

One request with a temporary resolution rule

The addresses below are documentation examples. Replace them with your own authorized endpoint and its real destination IP.

curl --noproxy '*' --resolve app.example.com:443:192.0.2.10 --connect-timeout 10 --max-time 20 -I https://app.example.com/
Enter fullscreen mode Exit fullscreen mode

The resolution rule applies to the specified hostname and port. The URL still carries app.example.com, so curl can use that hostname for TLS identity checking and the HTTP request. The override lasts for this invocation. curl manual

--noproxy '*' makes this example a direct connection. Use it only where your network permits direct access. If your environment requires a proxy, investigate its routing behavior instead of assuming this command tests the intended server.

If the request fails, PKI Channel’s TLS debugging checklist helps separate the requested hostname, the server’s certificate list and the client’s trust decision. Preserve those observations before changing another condition.

Why the common alternatives differ

Attempt Problem
Open https://192.0.2.10/ The URL asks to verify an IP identity
Add only an HTTP Host header The HTTP header does not by itself set the TLS name
Use --insecure The test no longer establishes normal certificate validation
Use --resolve with the hostname URL Destination changes while the intended hostname remains

TLS negotiation happens before the HTTP request is processed. A virtual host can therefore select a certificate before it sees your manually supplied HTTP header. Name resolution, SNI, certificate identity and HTTP routing belong to related but distinct parts of the request. RFC 9525 — Service Identity in TLS / RFC 8446 — TLS 1.3

What to record before the DNS switch

Record the exact command, destination address, time, curl version and response. Check the certificate identity and the application response separately. A HEAD request may return 405 Method Not Allowed on an application that does not support HEAD. That is different from a failed TLS handshake.

For an application test, request a small known public health resource according to your service's design. Avoid sending production credentials to a candidate environment until its identity and intended data handling have been established.

Repeat the request for each candidate destination. If one address serves an old certificate while another serves the new one, changing DNS may expose users to inconsistent behavior. A single successful request is not evidence about every node.

The pre-cutover result becomes easier to reuse with a certificate, deployment and observation inventory. Keep the test IP and the later public endpoint as separate observations so the earlier success does not silently stand in for the cutover check.

After the cutover

Run a normal request without --resolve from relevant client locations. The override test answered “does this address serve the intended hostname?” The normal request answers “where do clients actually go now?” Keep both results in the migration record.

This technique does not validate authoritative DNS, all caches, every geographic route or a CDN's managed certificate behavior. It gives you a narrow, useful test whose connection target and identity are explicit.

Primary sources

Top comments (0)