Sub-resource integrity breaks CSS

120 Views Asked by At

I have a very simple web page with some tables, with a very simple CSS file. When trying to add SRI, the CSS completely stops loading, despite the hash being provided. Here is the CSS :

table,
td,
th {
    border: 1px solid black;
}

td,
th {
    padding: 5px;
}

and the relevant code of the html page :

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Tables</title>
    <link rel="stylesheet" href="tables.css"
        integrity="sha384-Ra8hXflH9FmBW7JYCsWx2T0y5ArSUFunMLGGpENlPZPmWvZ8mEKN86iDTUdNwtQW">
</head>

<body>
    <!-- A table to check that the css is loading -->

    <table>
        <tbody>
            <tr>
                <td>1</td>
                <td>2</td>
                <td>3</td>
            </tr>
        </tbody>
    </table>
</body>

</html>

The key was generated using the command openssl dgst -sha384 -binary tp/tables.css | openssl base64 -A on macOS Ventura 13.1

When opening the console the following error is shown :

Cannot load stylesheet file:///Users/ambrosine/Developer/Web/tables.css. Failed integrity metadata check. Content length: 70, Expected content length: 70, Expected metadata: sha384-Ra8hXflH9FmBW7JYCsWx2T0y5ArSUFunMLGGpENlPZPmWvZ8mEKN86iDTUdNwtQW
0

There are 0 best solutions below