I was getting the annoying 'invalid certificate' message when trying to run/debug my web app using the IDE. The usual reason for this is that the device's time and date aren't set, but this wasn't that, and so I had a long 'trial and error' session to track the problem down.
The solution I found was removing a single file I had created in error 'readme~' fixed it. I guess the '~' causes a problem, but I can't be sure.
I hope this helps someone...