# RSA 密钥大小 1024 位太小：密钥交换失败

- **ID:** `security/weak-rsa-key-size-rejected`
- **领域:** security
- **类别:** config_error
- **错误码:** `SSL_R_WRONG_RSA_KEY_SIZE`
- **验证级别:** ai_generated
- **修复率:** 92%

## 根因

RSA 密钥仅为 1024 位，低于建议的最小大小（2048 位），被安全策略拒绝。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| OpenSSL 1.1.1 | active | — | — |
| OpenSSL 3.0 | active | — | — |
| Java 8 | active | — | — |
| Java 11 | active | — | — |
| Nginx 1.20 | active | — | — |

## 解决方案

1. ```
   生成新的 2048 或 4096 位 RSA 密钥。OpenSSL：`openssl genrsa -out newkey.pem 2048`，然后重新签发证书。
   ```
2. ```
   如果您控制客户端，可以配置其仅用于测试时允许 1024 位密钥，例如 Java：`-Djava.security.properties=...` 放宽策略，但避免在生产环境中使用。
   ```
3. ```
   改用 ECDSA 密钥（例如 P-256），它使用较小的密钥大小提供等效安全性：`openssl ecparam -genkey -name prime256v1 -out eckey.pem`。
   ```

## 无效尝试

- **** — Increasing the key size on the server without regenerating the certificate doesn't work; the certificate is separate from the key. (80% 失败率)
- **** — Setting the cipher suite to a different RSA variant doesn't change the key size requirement. (60% 失败率)
- **** — Disabling the security policy globally is not recommended and often fails due to other compliance checks. (50% 失败率)
