我在脚本源中有许多sha256散列。chrome在第一个上给了我这个错误;
The Content-Security-Policy directive name ''sha256-OIf-redacted-bJEXc='' contains one or more invalid characters. Only ASCII alphanumeric characters or dashes '-' are allowed in directive names.
编辑后的部分只包含a-zA-Z0-9\-
如果我删除引号(唯一不符合规则的字符),它根本无法识别该部分。
我被误认为这个错误消息是误导性的,散列也有其他问题。
这里真正的问题是什么?为什么chrome不接受这些指令?
头文件看起来像这样:default-src 'none'; script-src 'self' https://consentcdn.cookiebot.com/ https://consent.cookiebot.com/ ; 'sha256-e-redacted-A=' ...more stuff...
发布于 2021-07-02 17:19:29
Chrome认为你的hash是一个指令。
您应该首先插入指令,在本例中应该是script-src或default-src,然后添加您的源代码,如散列、'self‘或指定的域。
看起来你是在插入一个像指令一样的源代码。CSP的结构是...;...;...另请参阅https://content-security-policy.com/
https://stackoverflow.com/questions/68221978
复制相似问题