#!/bin/bash # HTTPS Auto-Trust Test Script for Ubuntu echo "๐Ÿ” Testing mkcert Web UI HTTPS Auto-Trust on Ubuntu" echo "==================================================" # Check if mkcert is installed if ! command -v mkcert &> /dev/null; then echo "โŒ mkcert not found. Please install mkcert first." exit 1 fi # Check if CA is installed if [ ! -f "$(mkcert -CAROOT)/rootCA.pem" ]; then echo "โš ๏ธ mkcert CA not installed. Installing..." mkcert -install fi echo "โœ… mkcert CA location: $(mkcert -CAROOT)" # Start the server with HTTPS in background echo "๐Ÿš€ Starting server with HTTPS..." ENABLE_HTTPS=true npm start & SERVER_PID=$! # Wait for server to start sleep 5 # Test HTTP echo "๐ŸŒ Testing HTTP endpoint..." if curl -s http://localhost:3000/api/status | grep -q "success"; then echo "โœ… HTTP endpoint working" else echo "โŒ HTTP endpoint failed" fi # Test HTTPS echo "๐Ÿ”’ Testing HTTPS endpoint..." if curl -s https://localhost:3443/api/status | grep -q "success"; then echo "โœ… HTTPS endpoint working (certificate trusted!)" else echo "โš ๏ธ HTTPS endpoint failed - checking certificate..." curl -k https://localhost:3443/api/status >/dev/null 2>&1 && echo "โœ… HTTPS works with certificate bypass" fi # Check SSL certificate echo "๐Ÿ” Checking auto-generated SSL certificate..." if [ -f "ssl/localhost.pem" ]; then echo "โœ… SSL certificate found: ssl/localhost.pem" echo "๐Ÿ“‹ Certificate details:" openssl x509 -in ssl/localhost.pem -noout -subject -issuer -dates else echo "โŒ SSL certificate not found" fi # Test certificate validation echo "๐Ÿ” Testing certificate validation..." if openssl verify -CAfile "$(mkcert -CAROOT)/rootCA.pem" ssl/localhost.pem >/dev/null 2>&1; then echo "โœ… Certificate validates against mkcert CA" else echo "โŒ Certificate validation failed" fi # Cleanup echo "๐Ÿงน Cleaning up..." kill $SERVER_PID 2>/dev/null wait $SERVER_PID 2>/dev/null echo "" echo "๐ŸŽ‰ Test complete! Access your HTTPS mkcert Web UI at:" echo " https://localhost:3443" echo "" echo "To start with HTTPS permanently:" echo " ENABLE_HTTPS=true npm start"