Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 144256 - Some queries fail when using SSL and unsigned certificates
Summary: Some queries fail when using SSL and unsigned certificates
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: dev   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nathan Hapke CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 142332 147661 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-29 11:52 EDT by Nathan Hapke CLA
Modified: 2006-07-11 03:42 EDT (History)
5 users (show)

See Also:


Attachments
Attach Context accepts all SSL certificates (5.47 KB, patch)
2006-06-22 17:39 EDT, Nathan Hapke CLA
no flags Details | Diff
mylar/context/zip (3.04 KB, application/octet-stream)
2006-06-22 20:08 EDT, Mik Kersten CLA
no flags Details
Certificates Patch (25.59 KB, patch)
2006-06-23 15:54 EDT, Nathan Hapke CLA
no flags Details | Diff
mylar/context/zip (39.98 KB, application/octet-stream)
2006-06-23 15:54 EDT, Nathan Hapke CLA
no flags Details
Certificates Patch (11.84 KB, patch)
2006-06-23 16:50 EDT, Nathan Hapke CLA
no flags Details | Diff
Re-made the patch (20.12 KB, patch)
2006-06-26 18:15 EDT, Nathan Hapke CLA
no flags Details | Diff
mylar/context/zip (43.04 KB, application/octet-stream)
2006-06-26 18:16 EDT, Nathan Hapke CLA
no flags Details
New test case (2.95 KB, patch)
2006-07-07 12:51 EDT, Nathan Hapke CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Hapke CLA 2006-05-29 11:52:44 EDT
When using a bugzilla server via HTTPS to a server with un-officially signed certificates, you cannot attach a context, nor create a new repository query.

Dialog comes up saying:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Please check your settings in the bugzilla preferences.

On Windows if you open a browser window inside eclipse and tell IE to accept the certificate, then they work.

eclipse 3.2rc6 / mylar dev build may 26th, both windows and linux.
Comment 1 Robert Elves CLA 2006-05-29 19:58:47 EDT
*** Bug 142332 has been marked as a duplicate of this bug. ***
Comment 2 Eugene Kuleshov CLA 2006-05-29 23:03:01 EDT
I wonder if you should use dummy cetificate store and trust manager and allow to add certificates to the store on user's request.
Comment 3 Nathan Hapke CLA 2006-06-13 11:56:31 EDT
Linux update: Repository synchronizing works, but context attaching is still a no-go.
Comment 4 Nathan Hapke CLA 2006-06-22 17:39:28 EDT
Created attachment 45126 [details]
Attach Context accepts all SSL certificates

Adds a factory to take advantage of the already in use TrustAll with the HttpClient.
Comment 5 Mik Kersten CLA 2006-06-22 19:15:18 EDT
*** Bug 147661 has been marked as a duplicate of this bug. ***
Comment 6 Mik Kersten CLA 2006-06-22 20:08:47 EDT
Created attachment 45136 [details]
mylar/context/zip
Comment 7 Mik Kersten CLA 2006-06-22 20:09:32 EDT
Patch applied, and manually tested, great work Nathan.  Nits:
- we never dump exceptions, so take a look at the way I made getSslSocket use MylarStatusHandler
- note the capitalization change of SSL in the type and method to follow our coding guidelines
- please attach a context when you submit patches
- it would be great if you submitted a unit test for this.  It doesn't need to do much or connext to a server, just making a test call createSocket and check that the socket was created correctly will suffice.
Comment 8 Eugene Kuleshov CLA 2006-06-22 21:52:14 EDT
Guys, are you sure it is really good idea to register protocol handler globally like this?

Protocol.registerProtocol("https", new Protocol("https", new TrustAllSslProtocolSocketFactory(), 443))

It would be safer to add it per request...
Comment 9 Mik Kersten CLA 2006-06-22 22:24:49 EDT
That's a very good catch Eugene and I was sloppy in my review.  

Nathan: this could cause problems for things like webtools registering different protocol handlers.  Also, currently the handler is registered every time we upload.  I have commented out the registration for now.  Could you please submit a patch with Eugene's suggestion?
Comment 10 Nathan Hapke CLA 2006-06-23 15:54:00 EDT
Created attachment 45208 [details]
Certificates Patch

Mik, Eugene: thanks for the comments.

Added a couple tests and localized the protocol change.
Comment 11 Nathan Hapke CLA 2006-06-23 15:54:14 EDT
Created attachment 45209 [details]
mylar/context/zip
Comment 12 Nathan Hapke CLA 2006-06-23 16:50:51 EDT
Created attachment 45216 [details]
Certificates Patch

Change set was tracking an extra file, this patch is cleaner.
Comment 13 Mik Kersten CLA 2006-06-25 15:11:44 EDT
This approach looks good to me.  Eugene, if you have any concerns with it please voice them.   Nathan, you will need to re-create the patch to the test case because that class has changed in HEAD.

		PostMethod postMethod;
		if (repositoryUsesHttps(repositoryUrl)) {
			Protocol acceptAllSsl = new Protocol("https", new TrustAllSslProtocolSocketFactory(), getSslPort(repositoryUrl));
			client.getHostConfiguration().setHost(getDomain(repositoryUrl), getSslPort(repositoryUrl), acceptAllSsl);
			
			postMethod = new PostMethod(getRequestPath(repositoryUrl) + POST_ARGS_ATTACHMENT_UPLOAD);
		}
		else {
			postMethod = new PostMethod(repositoryUrl + POST_ARGS_ATTACHMENT_UPLOAD);
		}
Comment 14 Nathan Hapke CLA 2006-06-26 18:15:36 EDT
Created attachment 45340 [details]
Re-made the patch
Comment 15 Nathan Hapke CLA 2006-06-26 18:16:42 EDT
Created attachment 45341 [details]
mylar/context/zip
Comment 16 Mik Kersten CLA 2006-06-26 19:30:59 EDT
Patch applied and manually tested, nice work Nathan.

I did not include the changes to ExistingBugEditor and assume that they were unintentional.
Comment 17 Nathan Hapke CLA 2006-06-26 19:34:46 EDT
Oh, sorry about that, must have accidentally slid in.
Comment 18 Nathan Hapke CLA 2006-07-07 12:50:45 EDT
Mik, I have been unable to replicate your failure on the test cases, even on my laptop running xp home with the windows firewall enabled.  However, I've come up with a slightly better approach for the test case, with any luck it will be more reliable.

Instead of binding to a particular interface on a particular port, it will now try to bind to 0.0.0.0:0, and let the kernel pick what interface/port.  I tested this on windows and linux, passes on both.
Comment 19 Nathan Hapke CLA 2006-07-07 12:51:18 EDT
Created attachment 45938 [details]
New test case
Comment 20 Mik Kersten CLA 2006-07-07 17:32:36 EDT
Patch applied and verified.  Good stuff Nathan.