CA证书包路径失效时退回系统证书库,修复附件上传 CONFIG_INVALID
- DifyRequiredAttachmentUpload:配置的 ca_file 不存在或不可读时记 warning 并改用系统证书库,仍校验对端证书与主机名 - DifyWorkflowRunStatus:同样处理,不再返回 RUN_STATUS_CONFIG_INVALID Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -284,7 +284,16 @@ final class DifyRequiredAttachmentUpload
|
||||
if (!array_key_exists('skip_missing', $options)) $options['skip_missing'] = true;
|
||||
if (!is_bool($options['skip_missing'])) self::fail('CONFIG_INVALID');
|
||||
$caFile = $options['ca_file'] ?? '';
|
||||
if (!is_string($caFile) || ($caFile !== '' && (!is_file($caFile) || !is_readable($caFile)))) self::fail('CONFIG_INVALID');
|
||||
if (!is_string($caFile)) self::fail('CONFIG_INVALID');
|
||||
if ($caFile !== '' && (!is_file($caFile) || !is_readable($caFile))) {
|
||||
// CA 证书包是可选项:路径失效(如 .env 沿用了其他机器的路径)时退回系统证书库,
|
||||
// 仍校验对端证书与主机名,不再让所有 AI 请求因此失败。
|
||||
if (class_exists(\think\facade\Log::class)) {
|
||||
try { \think\facade\Log::warning('dify attachment ca_file unreadable, using system CA store'); }
|
||||
catch (\Throwable $ignored) {}
|
||||
}
|
||||
$caFile = '';
|
||||
}
|
||||
$options['ca_file'] = $caFile;
|
||||
$options['resolved_hosts'] = self::resolvedHosts(array_key_exists('resolved_hosts', $options)
|
||||
? $options['resolved_hosts'] : []);
|
||||
|
||||
@@ -41,10 +41,11 @@ final class DifyWorkflowRunStatus
|
||||
$upload = array_key_exists('required_attachment_upload', $config) ? $config['required_attachment_upload'] : [];
|
||||
$caFile = is_array($upload) ? (array_key_exists('ca_file', $upload) ? $upload['ca_file'] : '') : null;
|
||||
$root = is_string($baseUrl) ? self::apiRoot($baseUrl) : null;
|
||||
// 可选 CA 证书包路径失效时退回系统证书库(仍校验证书),与附件上传保持一致。
|
||||
if (is_string($caFile) && $caFile !== '' && (!@is_file($caFile) || !@is_readable($caFile))) $caFile = '';
|
||||
if ($root === null || !is_string($apiKey) || $apiKey === '' || strlen($apiKey) > 4096
|
||||
|| preg_match('/[^\x21-\x7e]/', $apiKey) !== 0
|
||||
|| !is_string($caFile) || preg_match('/[\x00-\x1f\x7f]/', $caFile) !== 0
|
||||
|| ($caFile !== '' && (!@is_file($caFile) || !@is_readable($caFile)))) {
|
||||
|| !is_string($caFile) || preg_match('/[\x00-\x1f\x7f]/', $caFile) !== 0) {
|
||||
return self::error('RUN_STATUS_CONFIG_INVALID');
|
||||
}
|
||||
unset($config, $models, $model, $upload, $baseUrl);
|
||||
|
||||
Reference in New Issue
Block a user