Bug 531341 - [Webkit2] Can't access self signed web sites using internal web browser on fedora 27
Summary: [Webkit2] Can't access self signed web sites using internal web browser on fe...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 4.9 M2   Edit
Assignee: Eric Williams CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2018-02-19 08:24 EST by Jeff MAURY CLA
Modified: 2021-10-29 11:49 EDT (History)
7 users (show)

See Also:


Attachments
pof screenshot (566.58 KB, image/png)
2018-02-21 12:14 EST, Leo Ufimtsev CLA
no flags Details
Screenshot of how it looks on OSX (2.67 MB, image/jpeg)
2018-02-21 12:18 EST, Leo Ufimtsev CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff MAURY CLA 2018-02-19 08:24:44 EST
Installed Oxygen.2 for Java developers on stock Fedora 27.
I can't connect from the internal web browser window to a site that has a self signed certificate. The browser displays 'Unacceptable TLS certificate'
Am I missing some kind of settings ?
Comment 1 Alexander Kurtakov CLA 2018-02-19 08:48:46 EST
Would you please point to a site that fails for you?
Comment 2 Jeff MAURY CLA 2018-02-19 09:09:37 EST
Not easily as it has been reported from a customer internal OpenShift cluster. I reproduced it using Minishift and/or CDK and trying to connect from the internal web browser to https://${minishift ip}:8443
Comment 3 Alexander Kurtakov CLA 2018-02-21 09:33:19 EST
OK. I have reproduced it with https://self-signed.badssl.com/ . Leo, what do you think about having a way to ask the user whether he wants to trust the certificate? I don't feel comfortable even trying to blindly approve all self-signed certificates.
Comment 4 Jeff MAURY CLA 2018-02-21 10:02:01 EST
+1 on getting user approval otherwise would be a blocker from a security POV
Comment 5 Leo Ufimtsev CLA 2018-02-21 12:14:09 EST
I implemented proof of concept:
https://git.eclipse.org/r/#/c/117884/

One can overcome the TLS if one downloads the certificate and tells Webkit to allow certificates from a given host.

To implement this, we'd need:
1) Implement mechanism that detects that a page has a self-signed certificate
2) Implement prompt that tells user about issue and asks him if he wants to proceed anyway.
3) Download certificate. Tell Webkit to accept certificate from given host. (note, 'http:// part is omitted).

As a note, this already works on Cocoa and is handled by the browser. But with Webkit we have to implement it manually.
Comment 6 Leo Ufimtsev CLA 2018-02-21 12:14:56 EST
Created attachment 272796 [details]
pof screenshot
Comment 7 Leo Ufimtsev CLA 2018-02-21 12:17:46 EST
Technical notes:

Examples that can be used for inspiration:
https://github.com/WebKit/webkit/blob/master/Tools/MiniBrowser/gtk/BrowserTab.c#L151
https://github.com/vain/lariza/blob/master/browser.c#L1082
webkit/Tools/TestWebKitAPI/Tests/WebKitGLib/TestSSL.cpp
Comment 8 Leo Ufimtsev CLA 2018-02-21 12:18:42 EST
Created attachment 272798 [details]
Screenshot of how it looks on OSX
Comment 9 Leo Ufimtsev CLA 2018-02-26 10:38:48 EST
Note to self:

WebKitWebContext description snippet:
TLS certificate validation failure is now treated as a transport error by default. To handle TLS failures differently, you can connect to “load-failed-with-tls-errors”. Alternatively, you can use webkit_web_context_set_tls_errors_policy() to set the policy WEBKIT_TLS_ERRORS_POLICY_IGNORE; however, this is not appropriate for Internet applications.
Comment 10 Alexander Kurtakov CLA 2018-02-26 10:51:01 EST
(In reply to Leo Ufimtsev from comment #9)
> Note to self:
> 
> WebKitWebContext description snippet:
> TLS certificate validation failure is now treated as a transport error by
> default. To handle TLS failures differently, you can connect to
> “load-failed-with-tls-errors”. Alternatively, you can use
> webkit_web_context_set_tls_errors_policy() to set the policy
> WEBKIT_TLS_ERRORS_POLICY_IGNORE; however, this is not appropriate for
> Internet applications.

So a handler for load-failed-with-tls-errors is needed and some popup to ask whether to continue ignoring the tls error should be implemented.
Comment 11 Leo Ufimtsev CLA 2018-02-26 11:44:44 EST
(In reply to Alexander Kurtakov from comment #10)
> (In reply to Leo Ufimtsev from comment #9)
> > Note to self:
> > 
> > WebKitWebContext description snippet:
> > TLS certificate validation failure is now treated as a transport error by
> > default. To handle TLS failures differently, you can connect to
> > “load-failed-with-tls-errors”. Alternatively, you can use
> > webkit_web_context_set_tls_errors_policy() to set the policy
> > WEBKIT_TLS_ERRORS_POLICY_IGNORE; however, this is not appropriate for
> > Internet applications.
> 
> So a handler for load-failed-with-tls-errors is needed and some popup to ask
> whether to continue ignoring the tls error should be implemented.

Yea basically. But also download the certificate to some temp cache and load it as done in proof of concept patch.
Comment 12 Lakshmi P Shanmugam CLA 2018-03-02 02:38:39 EST
(In reply to Leo Ufimtsev from comment #5) 
> As a note, this already works on Cocoa and is handled by the browser. But
> with Webkit we have to implement it manually.

Hi Leo,
Not sure how useful it is for gtk, the Webkit port for windows has an SWT implementation for the Invalid Certificate Dialog. 
Please see: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/win32/org/eclipse/swt/browser/WebFrameLoadDelegate.java
Comment 13 Leo Ufimtsev CLA 2018-04-13 16:42:53 EDT
It would be nice to have this enhancement on gtk side, but at the moment gtk3 blockers/ui issues seem to have a higher priority. Once those are resolved we could potentially look into this more special-purpose use case.
Comment 14 Andre Dietisheim CLA 2018-07-04 08:52:31 EDT
This bug is very serious for linux users that try to connect our Eclipse based tooling for OpenShift to a cluster that's using self-signed certificates. We'd thus highly appreciate if this could be fixed in a timely manner. 
Alexander Kurtakov, is there any ETA?
Comment 15 Alexander Kurtakov CLA 2018-07-04 09:00:27 EDT
(In reply to Andre Dietisheim from comment #14)
> This bug is very serious for linux users that try to connect our Eclipse
> based tooling for OpenShift to a cluster that's using self-signed
> certificates. We'd thus highly appreciate if this could be fixed in a timely
> manner. 
> Alexander Kurtakov, is there any ETA?

No ETA, right now. Will look into it and try to give some soon.
Comment 16 Alexander Kurtakov CLA 2018-07-04 09:38:48 EDT
(In reply to Lakshmi Shanmugam from comment #12)
> (In reply to Leo Ufimtsev from comment #5) 
> > As a note, this already works on Cocoa and is handled by the browser. But
> > with Webkit we have to implement it manually.
> 
> Hi Leo,
> Not sure how useful it is for gtk, the Webkit port for windows has an SWT
> implementation for the Invalid Certificate Dialog. 
> Please see:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.
> eclipse.swt/Eclipse%20SWT%20WebKit/win32/org/eclipse/swt/browser/
> WebFrameLoadDelegate.java

Lakshmi, I looked at the windows port and I failed to find it storing the certificate somewhere and whitelisting it for later usage so it is per http session?
Comment 17 Leo Ufimtsev CLA 2018-07-04 10:28:48 EDT
(In reply to Alexander Kurtakov from comment #16)
> (In reply to Lakshmi Shanmugam from comment #12)
> > (In reply to Leo Ufimtsev from comment #5) 
> > > As a note, this already works on Cocoa and is handled by the browser. But
> > > with Webkit we have to implement it manually.
> > 
> > Hi Leo,
> > Not sure how useful it is for gtk, the Webkit port for windows has an SWT
> > implementation for the Invalid Certificate Dialog. 
> > Please see:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.
> > eclipse.swt/Eclipse%20SWT%20WebKit/win32/org/eclipse/swt/browser/
> > WebFrameLoadDelegate.java
> 
> Lakshmi, I looked at the windows port and I failed to find it storing the
> certificate somewhere and whitelisting it for later usage so it is per http
> session?

As a side note, my initial P.O.C wasn't based on Windows implementation. It's just the first thing that crossed my mind. I never looked at windows implementation when I did the P.O.C.
Comment 18 Eric Williams CLA 2018-07-04 14:38:53 EDT
I'll investigate.
Comment 19 Lakshmi P Shanmugam CLA 2018-07-05 03:02:46 EDT
(In reply to Alexander Kurtakov from comment #16)
> (In reply to Lakshmi Shanmugam from comment #12)
> > (In reply to Leo Ufimtsev from comment #5) 
> > > As a note, this already works on Cocoa and is handled by the browser. But
> > > with Webkit we have to implement it manually.
> > 
> > Hi Leo,
> > Not sure how useful it is for gtk, the Webkit port for windows has an SWT
> > implementation for the Invalid Certificate Dialog. 
> > Please see:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.
> > eclipse.swt/Eclipse%20SWT%20WebKit/win32/org/eclipse/swt/browser/
> > WebFrameLoadDelegate.java
> 
> Lakshmi, I looked at the windows port and I failed to find it storing the
> certificate somewhere and whitelisting it for later usage so it is per http
> session?

Hi Alex,
The Windows implementation doesn't store the certificate anywhere. 
IIRC, we didn't find a way/API to invoke the native certificate dialog or write to the certificate store. So, SWT creates it's own dialog similar to the one on Cocoa (https://bugs.eclipse.org/bugs/attachment.cgi?id=272798). All the actions such as showing the certificate, continue, cancel are implemented by SWT.

The Cocoa Webkit implementation is different, when there is a certificate error, SWT invokes the dialog provided by Cocoa and it takes care of all the actions.
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/cocoa/org/eclipse/swt/browser/WebKit.java#n702
Comment 20 Eric Williams CLA 2018-07-05 09:05:55 EDT
We don't need to store the certificate on Linux either, there is a way to get the certificate via callback and set the policy to ignore TLS warnings on it -- all using Webkit API, no storage needed.
Comment 21 Eclipse Genie CLA 2018-07-05 10:18:06 EDT
New Gerrit change created: https://git.eclipse.org/r/125636
Comment 22 Alexander Kurtakov CLA 2018-07-05 10:23:06 EDT
(In reply to Eclipse Genie from comment #21)
> New Gerrit change created: https://git.eclipse.org/r/125636

This patch adds a system property (-Dorg.eclipse.swt.internal.webkitgtk.ignoretlserrors=true ) to allow setting webkitgtk to ignore tls/ssl issues (like webkit1 did). Should be useful for developers as they would not have to go through the same accept error/warning when working with self signed certificates.
Lakshmi, I think it would be nice if there was smth like -Dorg.eclipse.swt.webkit.ignoretlserrors that applies for all OSes but it depends on whether there is interest from mac/win side.
Comment 24 Eric Williams CLA 2018-07-05 12:48:00 EDT
(In reply to Eclipse Genie from comment #23)
> Gerrit change https://git.eclipse.org/r/125636 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=dca8ee994b2a4a77c38d398512ee5e53a9c77a6b

Patch with the flag for ignoring all TLS errors is in master now. I am working on adding a dialog box that will allow for user input on a case by case basis.
Comment 26 Eric Williams CLA 2018-07-06 13:22:30 EDT
(In reply to Eclipse Genie from comment #25)
> Gerrit change https://git.eclipse.org/r/125666 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=a8f4d8012ebe238243cfee7b3a063bd66a2b6f00

Patch adding a dialog box to prompt the user is in master now. Jeff/Andre, please try with an I-build next week to confirm the issue is fixed for you.
Comment 27 Leo Ufimtsev CLA 2018-07-06 14:16:42 EDT
(In reply to Eric Williams from comment #26)
> (In reply to Eclipse Genie from comment #25)
> > Gerrit change https://git.eclipse.org/r/125666 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=a8f4d8012ebe238243cfee7b3a063bd66a2b6f00
> 
> Patch adding a dialog box to prompt the user is in master now. Jeff/Andre,
> please try with an I-build next week to confirm the issue is fixed for you.

Congrats on your first Webkit contribution.
Comment 28 Alexander Kurtakov CLA 2018-07-09 05:20:11 EDT
Testing with https://badssl.com/ (expired, wrong host ...) always says it's self-signed in the dialog. Either the dialog should be changed to more generic message "invalid SSL" or if possible the exact problem should be shown.
Comment 29 Lakshmi P Shanmugam CLA 2018-07-09 08:48:14 EDT
(In reply to Eric Williams from comment #26)
> (In reply to Eclipse Genie from comment #25)
> > Gerrit change https://git.eclipse.org/r/125666 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> > ?id=a8f4d8012ebe238243cfee7b3a063bd66a2b6f00
> 
Hi Eric,
We shouldn't hard code the text in English in the MessageBox, it should be able to use the localized text if it's available. You can use the Compatibility.getMessage() method and any existing keys from SWTMessages.properties. 
You can add a new key with new text, the localized text will be shown when it's translated and available in the SWTMessages_<locale>.properties file.
Comment 30 Eric Williams CLA 2018-07-09 10:27:47 EDT
I'll re-work the patch.
Comment 31 Eclipse Genie CLA 2018-07-09 15:58:34 EDT
New Gerrit change created: https://git.eclipse.org/r/125838
Comment 33 Eric Williams CLA 2018-07-10 13:30:01 EDT
(In reply to Eclipse Genie from comment #32)
> Gerrit change https://git.eclipse.org/r/125838 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=77730876131db1dee338b59ab954b3eb11345e9a

The patch using SWT.getMessage() and more detailed error messages has been merged. I'll add the German translations of the new keys sometime this week on babel.
Comment 34 Eclipse Genie CLA 2021-10-29 06:30:31 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187112
Comment 35 Eclipse Genie CLA 2021-10-29 06:55:33 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187113
Comment 36 Eclipse Genie CLA 2021-10-29 06:56:08 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187114
Comment 40 Eclipse Genie CLA 2021-10-29 11:48:27 EDT
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/187178