Fix HTTPS Certificate Error
GitHub ☯️ Medium Linux
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A minimal HTTPS webserver script (webserver.sh) listening on port 8443 fails to establish secure connections. The bundled SSL certificate (old_server.crt) lacks a Subject Alternative Name (SAN) for the local IP 127.0.0.1, causing hostname verification failures.

Task

Run the broken server and inspect the certificate to confirm the missing SAN. Generate a new self-signed certificate with SAN set to IP:127.0.0.1 and save it as server.crt and server.key. Update webserver.sh to use the new certificate files, launch the fixed server, and verify connectivity.

Example

# Before (Missing SAN)
subject=CN = wrong.example.com
curl: (60) SSL: no alternative certificate subject name matches target host name '1.1.1.1'

# After (SAN Present)
subject=CN = example
X509v3 Subject Alternative Name: IP Address:1.1.1.1
Hello World

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →