Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser Cache not working with self-signed certificate #2634

Closed
BobbyShoe opened this issue Jul 29, 2022 · 1 comment
Closed

Browser Cache not working with self-signed certificate #2634

BobbyShoe opened this issue Jul 29, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@BobbyShoe
Copy link

Description
When using a self-signed certificate and bypassing security warning using this suggested method:
await webView.CoreWebView2.CallDevToolsProtocolMethodAsync("Security.setIgnoreCertificateErrors", "{"ignore": true}");

browser cache appears to not be used when serving content, and the server is always hit for content being cached. If requests are switched to HTTP, caching appears to work fine.

If there any other suggested methods to get caching to work in WebView2 with a self signed certificate, please let me know.

Version
SDK: 1.0.1245.22
Runtime: 103.0.1264.44
Framework: WPF
OS: Win11

Repro Steps
Download an resource from a server secured with a self-signed certificate with the SSL warning suppressed. Try to download the resource again, and you can see the server is hit again to request the resource.

Here are two sample request and response headers from subsequent calls (that should pull from the local cache) using HTTP and using HTTPS with a self-signed certificate. You can see the HTTP method has "206 Partial Content (from disk cache)", which does not hit the server again.

// HTTP request
// Request Headers
Request URL: http://localhost/Commander/api/File/View/Demos%2FColts%20Vs%20Bills%202021?v=20220608091714
Request Method: GET
Status Code: 206 Partial Content (from disk cache)
Remote Address: [::1]:80
Referrer Policy: strict-origin-when-cross-origin

// Response Headers
Accept-Ranges: bytes
Cache-Control: private,max-age=2592000
Content-Length: 167273308
Content-Range: bytes 26738688-194011995/194011996
Content-Type: video/mp4
Date: Fri, 29 Jul 2022 16:01:12 GMT
ETag: "20220608051715"
Last-Modified: Wed, 08 Jun 2022 21:17:15 GMT
Server: Microsoft-HTTPAPI/2.0

// HTTPS Request with self signed certificate
// Request Headers
:authority: localhost
:method: GET
:path: /Commander/api/File/View/Demos%2FColts%20Vs%20Bills%202021?v=20220608091714
:scheme: https
accept: /
accept-encoding: identity;q=1, *;q=0
accept-language: en-US,en;q=0.9
range: bytes=29949952-
referer: https://localhost/app/slides/ce7421bb-71f1-4cfe-aabd-1996b79438af
sec-ch-ua: ".Not/A)Brand";v="99", "Microsoft Edge";v="103", "Chromium";v="103", "Microsoft Edge WebView2";v="103"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
sec-fetch-dest: video
sec-fetch-mode: no-cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.66 Safari/537.36 Edg/103.0.1264.44

// Response Headers
accept-ranges: bytes
cache-control: private,max-age=2592000
Content-Length: 164062044
Content-Range: bytes 29949952-194011995/194011996
content-type: video/mp4
date: Fri, 29 Jul 2022 16:29:33 GMT
etag: "20220608051715"
last-modified: Wed, 08 Jun 2022 21:17:15 GMT
server: Microsoft-HTTPAPI/2.0

@BobbyShoe BobbyShoe added the bug Something isn't working label Jul 29, 2022
@monica-ch
Copy link
Contributor

monica-ch commented Jul 31, 2022

@BobbyShoe This is a known issue with Chromium based browsers. It does not cache responses if the HTTPS connection is using an invalid Certificate. See this bug report for details: https://bugs.chromium.org/p/chromium/issues/detail?id=110649#c8.

Chromium treats a self-signed certificate as a certificate error (even after setting IgnoreCertificateErrors), and thus the site is not to be trusted fully.

Per my understanding, there isn't a way to get caching to work in WebView2 with a self signed/invalid certificate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants