tr069 协议中何时使用 basic auth 或者 http digest auth

更新日期: 2023-04-29 阅读次数: 771 字数: 824 分类: 物联网

由于没有在 TeamsACS 的 tr069 server 部分代码中没有找到 HTTP Digest Auth Middleware 的逻辑。 我开始怀疑我对 tr069 协议的 auth 部分理解有问题。所以查询了 tr069 协议文档。

参考:

  • https://www.broadband-forum.org/download/TR-069_Amendment-1.pdf 第一版,不推荐
  • https://www.broadband-forum.org/technical/download/TR-069_Amendment-5.pdf 推荐看第五版,这部分说明跟第一版有差异。这个文档真是又臭又长,还是的收藏到手机和 kindle 里,有空就翻翻。

里面有两个小结是讲述 Auth 的:

  • 3.4.4 Authentication
  • 3.4.5 Digest Authentication

Authentication

逐段翻译一下吧,边翻译,边理解:

If the CPE is not authenticated using TLS, the ACS MUST authenticate the CPE using HTTP. If TLS is being used for encryption, the ACS SHOULD use basic authentication 7. If TLS is not being used, then the ACS MUST use digest authentication.

  • 如果 CPE 未通过 TLS 进行认证,那么 ACS 必须通过 HTTP 对 CPE 进行认证。TLS 也能用于认证?TLS 不是只能用于加密?
  • 如何 TLS 被用于加密,那么 ACS 应该使用 basic auth。(这是 tr069 的第五版,然而第一版里写的是 basic auth 或者 http digest auth)
  • 如果未使用 TLS,那么 ACS 必须使用 digest auth。

后面两条比较好理解,第一条得继续查一下 TLS 认证的原理。再就是,TeamsACS 是否是因为启用 TLS 认证,所以 ACS 才没有使用 http digest 认证,而且还是用了一个残废版的 basic auth。

The CPE MUST support both HTTP basic and digest authentication. The ACS chooses the authentication scheme by virtue of providing a basic or digest authentication challenge. If TLS is being used for encryption, the CPE SHOULD preemptively send basic authentication credentials as defined in Section 2 of 7.

  • CPE 必须同时支持 HTTP basic auth 和 digest auth。具体使用哪一种取决于 ACS 指定了哪种 (由 ACS 发起 auth challenge)。
  • 如果使用了 TLS 加密,CPE 应该使用 basic auth。

这样看,CPE 模拟器不支持 digest auth 似乎也不是个问题。

Note – use of an authentication challenge requires the initial message (usually an Inform RPC method request) to be sent; use of preemptive basic authentication with TLS is secure and avoids the need for an additional request.

  • 在 ACS 向 CPE 发起 auth challenge 时,需要先有一个由 CPE 向 ACS 发起的初始化 message (即一个 Inform 类型的消息)
  • 如果 CPE 先发制人。。。优先发起 basic auth, 则不需要额外的请求

If the CPE has received an authentication challenge from the ACS (either basic or digest), the CPE SHOULD send an Authorization header in all subsequent HTTP requests for the duration of the TCP connection. Whether or not the CPE does this, the ACS MAY issue subsequent authentication challenges at any stage of the Session within a single or multiple TCP connections

如果 CPE 收到了来自 ACS 的 auth challenge, 无论是 basic auth 还是 digest auth, 在接下来的 http 请求中 CPE 要在请求头中加上 Authentication 信息。无论 CPE 是否这样做,ACS 都有可能在任何状态下发起 auth challenge.

CPE username/userid 和密码

这个 username 需要是唯一的,具体来说,推荐两种格式:

格式1:<OUI> "-" <ProductClass> "-" <SerialNumber>
格式2:<OUI> "-" <SerialNumber>

OUI 是 Organizationally unique identifier (OUI) “组织唯一标识符” 的缩写。

当然,这个格式不是强制的,我看国产的系统就有直接用随机字符串来作为 username 的。

密码必须每个 CPE 都不同。

tags: tr069

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式