【发布时间】:2023-03-29 06:59:02
【问题描述】:
Amazon S3 允许静态网站托管,但要求存储桶名称必须与您的域名匹配。这意味着您的存储桶名称将类似于:mydomain.com。 Amazon S3 还为 *.s3.amazonaws.com 提供通配符 SSL 证书。根据 TLS 的规则,这意味着 com.s3.amazonaws.com 被证书覆盖,但 mybucket.com.s3.amazonaws.com 不是。连接到 *.com.s3.amazonaws.com 的节点应用程序,例如 Knox,应该确实能够信任该证书,即使它违反了 TLS 规则,因为 knox 库是一个“封闭系统”:它只曾经连接到亚马逊资产。
Node模块https依赖tls.js,而tls.js有这个功能:
function checkServerIdentity(host, cert) {
...
// "The client SHOULD NOT attempt to match a presented identifier in
// which the wildcard character comprises a label other than the
// left-most label (e.g., do not match bar.*.example.net)."
// RFC6125
if (!wildcards && /*/.test(host) || /[.*].**/.test(host) ||
/*/.test(host) && !/*.*..+..+/.test(host)) {
return /$./;
}
这将正确返回“证书不匹配”错误。上层的 Knox 模块是否可以覆盖 checkServerIdentity 函数,该函数向下几层且不被 Knox 直接调用?我知道如何覆盖我需要的库中的函数,但不知道这些库包含的库。
【问题讨论】: