tauri: [feat] ignore ssl certificate errors
Describe the problem
My app lets users connect to self-hosted services that often use self-signed or otherwise untrusted ssl certificates. I cannot access these services with tauri because of certificate errors.
Describe the solution you’d like
Ideal solution would be a prompt that lets users chose to trust the certificate. Another way would be how electron handles it, you can hook to a certificate-error event and ignore the errors, something like this:
// SSL/TSL: this is the self signed certificate support
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
// On certificate error we disable default behaviour (stop loading the page)
// and we then say "it is all fine - true" to the callback
event.preventDefault();
callback(true);
});
Alternatives considered
Even a command line flag like chromiums --ignore-certificate-errors would be helpful.
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 16 (5 by maintainers)
Commits related to this issue
- feat(pve api): 集成pve rest api 前端访问https自签名证书会被拦截 https://github.com/tauri-apps/tauri/issues/4039 — committed to janeywong/HINEW by janeywong 2 years ago
That is one of the disable-security requests we get oftenly but aren’t planning on implementing anytime soon. Maybe we reconsider when we have more control over the webview.
Can you please share the example code?
Yea i get that, no worries 😃 Just for future readers, the idea proposed by @JonasKruckenberg works as expected. Thanks!
@realtebo Just to be sure, are you really talking about
httpor do you meanhttps? Forhttpcertificates should not matter, no?If it’s http, you’re using tauri v1, and you’re dealing with mixed-content errors (windows only) then try this setting https://v1.tauri.app/v1/api/config/#securityconfig.dangeroususehttpscheme - if not then we’ll need more info.
Under the hood, chromium allows flag to disable verification of certificates and also to allow fetching http resoureces.
We are in the main and vital need to connect to a local odata provider using http and we are stalled
Windows 10 + tauri 1.3.0 I have already tried and it works! My Steps:
http.rsin .cargo (C:/Users/**/.cargo/registry/src/**/tauri-1.3.0/src/api/http.rs), add one line just under line:136target/*in your project to recompile changesFinally you will find that you can use ClientBuilder and HttpRequestBuilder to access https apis under a self-signed certificate.
You got that right yeah! You can write some nicer JS abstraction on top of
invokethat replicates the same interfacefetchhas, so you wouldn’t even have to change your current code much