One of the most common issue with TFS/GIT users come across is the issue caused by self-signed certificates or the corporate certificates.
Error: SSL certificate problem: unable to get local issuer certificate
This Applied to:
TFS 2015 update 3
Android studio 2.1.2
We used Android studio and VSTS/TFS plugin to clone a GIT repository, we faced issues in retrieving the local issuer certificate. These are certificates that have not been signed by a known trusted certificate authority. The problem is that GIT/JAVA will not accept this certificate automatically. We need to force GIT/JAVA to accept the self-signed certificates.
Let’s now consider how to go about with the resolution,
Initially, we faced issues with TFS authentication,
Unable to authenticate to TFS ‘https://server:8080/tfs”. verify access to the server URL and try ‘Connect…’ again.
Very often this error can be interpreted to be the result of self-signed certificate. If the certificate in use is Self-signed or any other certificate that is private to the internal network. Java doesn’t trust such certificates and for which, we can import the cert into the trust store and make it to work.
The link explains how the certificate import works in a Linux machine (which is also applicable for Windows).
the “keytool” is under “<JAVA_HOME>\bin\keytool.exe”, and
the “cacerts” trust store is under “<JAVA_HOME>\jre\lib\security\cacerts”.
<JAVA_HOME> should be the jre/jdk installation used by IntelliJ.
This should have resolved the above TFS connectivity failure.
If you are using self-signed certificate, you may not be able to connect to TFS from the plugin
Error message: Caused by: javax.net.ssl.SSLPeerUnverifiedException: Host name ‘server’ does not match the certificate subject provided by the peer (CN=server.corp.fabricam.com)
After getting past the connectivity issue, there are instances in which we get error like the one below:
SSL certificate problem: unable to get local issuer certificate
In the android logs,
#git4idea.commands.GitHandler – fatal: unable to access ‘https://server/tfs/DefaultCollection/_git/gitRepo/‘: SSL certificate problem: unable to get local issuer certificate
Exception : javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
atcom.microsoft.alm.plugin.context.ServerContextManager.validateServerConnection(ServerContextManager.java:206) at com.microsoft.alm.plugin.context.ServerContextManager.validateServerConnection(ServerContextManager.java:171)
There are 2 methods of dealing with this issue.
1.Disable SSL verification using below command,
git config –global http.sslVerify false
If you disable SSL certificates verification, then you are susceptible to Man in middle attacks.
2.The preferred method is import certificate authority (CA) to trusted certificate authority store.
If we can verify that disabling SSL verification works, then this article may help:
But, in case if the article doesn’t help,
Try exporting the certificate in all the levels again, following the instructions on the blog.
Test certificates with curl.exe, to check if the SSL handshake is successful.
“c:\Program Files\Git\mingw64\bin\curl.exe” -v https://server-name -cacert c:\path\to\cert\file.cer
Now, import the certificate into the Git.exe cert store as we did before (also from blog). After importing the certificate, GIT clone’s files from the master branch.
For the complete encryption and the decryption, import the certificate into the Java cert store for Android Studio.
JRE that is now packaged with Android Studio 2.2. You can find it at the root of the Android Studio folder. “C:\program files\Android\Android Studio\jre”
Hope this helps!
Content: Ramandeep Singh
Review: Romit Gulati