You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Software_Architecture/distance-judgement/HTTPS_SETUP.md

99 lines
2.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 🔒 HTTPS设置指南
## 概述
本系统已升级支持HTTPS解决摄像头权限问题。现代浏览器要求HTTPS才能访问摄像头等敏感设备。
## 🚀 快速启动
### 方法一:自动设置(推荐)
1. 在PyCharm中打开项目
2. 直接运行 `main_web.py`
3. 系统会自动生成SSL证书并启动HTTPS服务器
### 方法二:手动安装依赖
如果遇到cryptography库缺失
```bash
pip install cryptography
```
## 📱 访问地址
启动后访问地址已升级为HTTPS
- **本地访问**: https://127.0.0.1:5000
- **手机访问**: https://你的IP:5000/mobile/mobile_client.html
## 🔑 浏览器安全警告处理
### 桌面浏览器
1. 访问 https://127.0.0.1:5000
2. 看到"您的连接不是私密连接"警告
3. 点击 **"高级"**
4. 点击 **"继续访问localhost(不安全)"**
5. 正常使用
### 手机浏览器
1. 访问 https://你的IP:5000/mobile/mobile_client.html
2. 出现安全警告时,点击 **"高级"** 或 **"详细信息"**
3. 选择 **"继续访问"** 或 **"继续前往此网站"**
4. 正常使用摄像头功能
## 📂 文件结构
新增文件:
```
ssl/
├── cert.pem # SSL证书文件
└── key.pem # 私钥文件
```
## 🔧 技术说明
### SSL证书特性
- **类型**: 自签名证书
- **有效期**: 365天
- **支持域名**: localhost, 127.0.0.1
- **算法**: RSA-2048, SHA-256
### 摄像头权限要求
- ✅ HTTPS环境 - 支持摄像头访问
- ❌ HTTP环境 - 浏览器阻止摄像头访问
- ⚠️ localhost - HTTP也可以但IP访问必须HTTPS
## 🐛 故障排除
### 问题1: cryptography库安装失败
```bash
# Windows
pip install --upgrade pip
pip install cryptography
# 如果还是失败,尝试:
pip install --only-binary=cryptography cryptography
```
### 问题2: 证书生成失败
1. 检查ssl目录权限
2. 重新运行程序,会自动重新生成
### 问题3: 手机无法访问
1. 确保手机和电脑在同一网络
2. 检查防火墙设置
3. 在手机浏览器中接受安全证书
### 问题4: 摄像头仍然无法访问
1. 确认使用HTTPS访问
2. 检查浏览器摄像头权限设置
3. 尝试不同浏览器Chrome、Firefox等
## 📋 更新日志
### v2.0 - HTTPS升级
- ✅ 自动SSL证书生成
- ✅ 完整HTTPS支持
- ✅ 摄像头权限兼容
- ✅ 手机端HTTPS支持
- ✅ 浏览器安全警告处理指南
## 🎯 下一步
完成HTTPS升级后您的移动端摄像头功能将完全正常工作不再受到浏览器安全限制的影响。