=========================================== CONFIGURACIÓN DE HTTPS EN XAMPP (WINDOWS) =========================================== PROBLEMA: Los navegadores modernos NO permiten acceder a la cámara sin HTTPS (excepto en localhost). SOLUCIONES: ============================================ OPCIÓN 1: USAR LOCALHOST (Más fácil) -------------------------------------------- Si estás accediendo desde http://localhost/SICA/... La cámara DEBERÍA funcionar porque localhost es una excepción de seguridad. Si NO funciona, intenta: 1. Usar http://127.0.0.1/SICA/ en lugar de localhost 2. Verificar que tu navegador tenga permisos de cámara: - Chrome/Edge: Configuración > Privacidad y seguridad > Permisos de cámara - Firefox: Preferencias > Privacidad y seguridad > Permisos > Cámara OPCIÓN 2: CONFIGURAR HTTPS EN XAMPP (Producción) -------------------------------------------- 1. DESCARGAR OPENSSL PARA WINDOWS - Descargar desde: https://slproweb.com/products/Win32OpenSSL.html - Instalar en C:\Program Files\OpenSSL-Win64 2. GENERAR CERTIFICADO SSL - Abrir CMD como administrador - Ejecutar: cd C:\xampp\apache\conf openssl genrsa -out server.key 2048 openssl req -new -key server.key -out server.csr -subj "/C=PE/ST=State/L=City/O=Organization/CN=localhost" openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt - Copiar los archivos generados: move server.key C:\xampp\apache\conf\ssl.key\ move server.crt C:\xampp\apache\conf\ssl.crt\ 3. CONFIGURAR APACHE - Editar C:\xampp\apache\conf\extra\httpd-ssl.conf - Buscar y modificar estas líneas: Listen 443 DocumentRoot "C:/xampp/htdocs/SICA" ServerName localhost:443 SSLEngine on SSLCertificateFile "conf/ssl.crt/server.crt" SSLCertificateKeyFile "conf/ssl.key/server.key" AllowOverride All Require all granted 4. ACTIVAR MÓDULO SSL EN APACHE - Abrir C:\xampp\apache\conf\httpd.conf - Buscar y descomentar (quitar # al inicio): LoadModule ssl_module modules/mod_ssl.so LoadModule socache_shmcb_module modules/mod_socache_shmcb.so - Buscar y descomentar: Include conf/extra/httpd-ssl.conf 5. REINICIAR APACHE - Abrir XAMPP Control Panel - Detener Apache - Iniciar Apache 6. ACCEDER VÍA HTTPS - Abrir navegador: https://localhost/SICA/asistencias/escanear_qr.php - Aceptar la advertencia de certificado (es auto-firmado, es normal) OPCIÓN 3: USAR UN SERVIDOR DE DESARROLLO CON HTTPS ---------------------------------------------------- Si tienes Node.js instalado, puedes crear un servidor HTTPS rápido: 1. Crear archivo server-https.js en C:\xampp\htdocs\SICA\: const https = require('https'); const fs = require('fs'); const http = require('http'); const options = { key: fs.readFileSync('C:/xampp/apache/conf/ssl.key/server.key'), cert: fs.readFileSync('C:/xampp/apache/conf/ssl.crt/server.crt') }; // Proxy para HTTP http.createServer((req, res) => { res.writeHead(301, { Location: 'https://' + req.headers['host'] + req.url }); res.end(); }).listen(80); // Servidor HTTPS https.createServer(options, (req, res) => { // Proxy requests to XAMPP const proxy = http.request({ hostname: 'localhost', port: 80, path: req.url, method: req.method }, (proxyRes) => { res.writeHead(proxyRes.statusCode, proxyRes.headers); proxyRes.pipe(res); }); req.pipe(proxy); }).listen(443); console.log('Servidor HTTPS corriendo en https://localhost'); 2. Ejecutar: node C:\xampp\htdocs\SICA\server-https.js SOLUCIÓN RÁPIDA PARA PRUEBAS: ================================ Si solo quieres probar la cámara RÁPIDAMENTE: 1. Instalar la extensión "Web Server for Chrome" en Chrome 2. Configurar el servidor para usar HTTPS 3. Apuntar a la carpeta C:\xampp\htdocs\SICA O usar Python (si está instalado): cd C:\xampp\htdocs\SICA python -m http.server 8443 --bind 127.0.0.1 Y luego acceder con: https://localhost:8443/asistencias/escanear_qr.php VERIFICACIÓN: ============ Para verificar que HTTPS está funcionando: 1. Abrir: https://localhost/SICA/ 2. Deberías ver el candado 🔒 en la barra de direcciones 3. Navegar a: https://localhost/SICA/asistencias/escanear_qr.php 4. Clic en "Iniciar Cámara" 5. Debería pedir permiso de cámara NOTAS IMPORTANTES: ================ - El certificado auto-firmado mostrará advertencia en el navegador (es NORMAL) - Los navegadores podrían bloquear la cámara si el certificado no es de confianza - Para producción, usar un certificado REAL (Let's Encrypt es GRATIS) - localhost SIEMPRE funciona sin HTTPS (excepción de seguridad de los navegadores)