---
title: "How to Test HTTPS and TLS via CLI with curl and OpenSSL"
url: "https://astraguardvpn.com/blog/how-to-test-https-and-tls-via-cli-with-curl-and-openssl"
description: "Learn how to test HTTPS, inspect TLS handshakes, and verify certificates using curl and OpenSSL from the command line."
updated: "2026-07-27T09:26:59.171Z"
---

# How to Test HTTPS and TLS via CLI with curl and OpenSSL

Dive into testing HTTPS, TLS, and certificates using curl and OpenSSL with realistic examples and technical depth.

Before You Start Testing HTTPS connections and their security parameters directly from the command line with tools like curl and OpenSSL s_client provides deep insights into how secure connections are established and maintained. Ensure you have curl and OpenSSL installed on your system. Note that incorrect commands can expose sensitive information or disrupt services, so proceed with caution. Technical Background HTTPS (Hypertext Transfer Protocol Secure) is a secure version of HTTP, achieved by layering HTTP over TLS (Transport Layer Security). TLS ensures data privacy and integrity through encryption and mutual authentication between the server and client. When a client (like a web browser or a command-line tool) connects to a server via HTTPS, a TLS handshake occurs. This process involves the client and server agreeing on encryption methods, verifying each other’s identities using digital certificates, and establishing a secure session key for encryption. Digital certificates, often issued by Certificate Authorities (CA), play a crucial role in this process by proving the identity of a server. They contain the server's public key and related metadata, providing the foundation for encrypted communication. Step By Step 1. Verify curl and OpenSSL Installation (Windows / macOS / Linux) Command: curl --version openssl version Ensure both commands return version information. If not, install the missing tool via your package manager or official website. 2. Test Basic HTTPS Connection with curl Command: curl -I https://example.com This retrieves HTTP headers, helping verify the server's response and SSL certificate information. 3. Inspect Certificate Details with OpenSSL Command: openssl s_client -connect example.com:443 -servername example.com This command initiates a connection to the server and displays detailed certificate information. Worked Example Example: Testing a Connection with curl Command: curl -v https://10.8.0.2 Expected Output: * Connected to 10.8.0.2 * SSL certificate verify ok. Example: Inspecting a Certificate with OpenSSL Command: openssl s_client -connect 10.8.0.2:443 -servername 10.8.0.2 Expected Output: Certificate chain 0 s:/CN=example.com Configuration Or Command Reference - -I: Fetches HTTP headers only. - -v: Verbose mode, provides more details about the SSL handshake. - --insecure: Allow connections to SSL sites without certificates. - -connect: Specifies the server and port to connect to. - -servername: Used for SNI (Server Name Indication) to specify the hostname. Troubleshooting Symptom: curl: (60) SSL certificate problem Likely Cause: The server's SSL certificate is self-signed or untrusted. Fix: Use --insecure for testing or add the certificate to your trusted store. Symptom: openssl: unable to get local issuer certificate Likely Cause: The server's certificate chain is incomplete. Fix: Verify the server's certificate configuration or use a complete CA bundle. Symptom: Connection refused Likely Cause: The server is not listening on the specified port or is down. Fix: Verify the server's status and port configuration. Related Concepts And Further Reading - SSL/TLS Protocols - Certificate Authorities - Public Key Infrastructure (PKI) - Server Name Indication (SNI) - HTTPS vs. HTTP Key Takeaways • HTTPS layers HTTP over TLS for secure communication. • curl and OpenSSL are powerful tools for testing and inspecting HTTPS connections. • The TLS handshake establishes a secure connection and involves certificate verification. • Understanding certificate details is crucial for debugging connection issues. • Properly configuring curl and OpenSSL ensures accurate test results. FAQ Q: What is the difference between HTTP and HTTPS? A: HTTPS is the secure version of HTTP, using TLS to encrypt data and verify server identity. Q: Can I use these tools to test any server? A: Yes, as long as the server supports TLS/SSL. However, ensure you have permission to test. Q: What does the -servername flag do in OpenSSL? A: It specifies the hostname for Server Name Indication (SNI), allowing multiple domains on the same IP.

---

[More articles](https://astraguardvpn.com/blog) · [VPN plans](https://astraguardvpn.com/packages)
