You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

FusionPBX v4.4二进制文件配置咨询:SNOM电话证书配置失败

解决FusionPBX v4.4提供DER格式证书给SNOM电话时的Smarty致命错误问题

我之前帮人处理过类似的FusionPBX和SNOM设备的配置问题,你遇到的这个Smarty致命错误,本质是因为模板引擎试图解析二进制的DER证书内容,而它只适合处理文本类的配置文件。这里有几个可行的解决办法:

方法一:新增独立脚本直接输出二进制证书

在FusionPBX的app/provision/目录下创建一个专门处理证书的PHP文件(比如get_der_cert.php),绕过Smarty直接输出二进制内容:

<?php
// 设置适配DER证书的HTTP头
header('Content-Type: application/x-x509-ca-cert');
header('Cache-Control: no-cache');

// 可以根据MAC参数加载对应设备的证书,这里示例用固定路径
$mac = $_GET['mac'] ?? '';
// 替换成你实际存储DER证书的路径,可根据MAC动态调整
$cert_file = "/var/www/fusionpbx/resources/certs/snom_{$mac}.der";

if (file_exists($cert_file)) {
    readfile($cert_file);
} else {
    http_response_code(404);
    echo "Certificate not found for MAC: {$mac}";
}
exit;
?>

之后在SNOM电话的配置里,把证书获取地址改成:
http://fusionpbx.example.com:80/app/provision/get_der_cert.php?mac=000413xxxxxx

方法二:修改现有provision脚本跳过Smarty编译

如果你不想新增文件,可以修改app/provision/provision.php(或者对应的入口脚本),在Smarty初始化前判断请求的是DER文件,直接输出内容:

<?php
// 在Smarty初始化代码之前添加这段逻辑
$requested_file = $_GET['file'] ?? '';
$file_ext = strtolower(pathinfo($requested_file, PATHINFO_EXTENSION));

// 判断是否为DER格式证书
if ($file_ext === 'der') {
    $cert_path = "/var/www/fusionpbx/resources/templates/provision/{$requested_file}";
    if (file_exists($cert_path)) {
        header('Content-Type: application/x-x509-ca-cert');
        readfile($cert_path);
        exit; // 终止脚本,跳过Smarty流程
    } else {
        http_response_code(404);
        echo "DER file not found: {$requested_file}";
        exit;
    }
}

// 原有Smarty初始化和配置逻辑继续执行
// ...
?>

这样你依然可以用原来的请求格式:
http://fusionpbx.example.com:80/app/provision/?mac=000413xxxxxx&file=mycert.der

验证步骤

  1. 直接在浏览器或curl中访问证书地址,确认能正常下载DER文件,没有报错
  2. 在SNOM电话上配置该地址,检查设备是否能成功加载证书并完成自动配置

内容的提问来源于stack exchange,提问作者Michael Schaefers

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:32:19