# javax.net.ssl.SSLException：无法识别的 SSL 消息，明文连接？

- **ID:** `java/ssl-exception-unrecognized-ssl-message`
- **领域:** java
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

JVM 尝试建立 SSL/TLS 连接，但服务器在预期的 SSL 端口上使用非 SSL 协议（通常是纯 HTTP），通常由端口配置错误或 URL 方案不正确引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Java 8 | active | — | — |
| Java 11 | active | — | — |
| Java 17 | active | — | — |
| Java 21 | active | — | — |

## 解决方案

1. ```
   Verify the correct URL scheme: use https:// for SSL connections and http:// for plain connections. Check the server's actual port configuration.
   ```
2. ```
   If the server supports both HTTP and HTTPS on different ports, ensure the client connects to the correct port. Use tools like curl to test: curl -v https://host:port.
   ```
3. ```
   For development or testing, if the server is misconfigured and you must use SSL, configure a reverse proxy (e.g., nginx) to terminate SSL and forward to the backend HTTP server.
   ```

## 无效尝试

- **** — Disabling SSL verification does not fix the protocol mismatch; the server is not speaking SSL at all. (95% 失败率)
- **** — Changing the SSL protocol version (e.g., TLSv1.2 to TLSv1.3) does not help because the server is not using SSL. (90% 失败率)
- **** — Increasing connection timeout does not change the protocol; the server still responds with plain HTTP. (95% 失败率)
