import javax.net.ssl.SSLHandshakeException;
+import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.NoRemoteRepositoryException;
import org.eclipse.jgit.errors.NotSupportedException;
import org.eclipse.jgit.errors.PackProtocolException;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.lib.SymbolicRef;
+import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.transport.HttpAuthMethod.Type;
import org.eclipse.jgit.transport.HttpConfig.HttpRedirectMode;
import org.eclipse.jgit.transport.http.HttpConnection;
if (trustNow || trustLocal || trustAlways) {
sslVerify = false;
if (trustAlways) {
- updateSslVerify(SystemReader.getInstance()
- .openUserConfig(null, FS.DETECTED),
- false);
+ updateSslVerifyUser(false);
} else if (trustLocal) {
updateSslVerify(local.getConfig(), false);
}
private void updateSslVerify(StoredConfig config, boolean value) {
// Since git uses the original URI for matching, we must also use the
// original URI and cannot use the current URI (which might be different
- // after redirects)
+ // after redirects).
String uriPattern = uri.getScheme() + "://" + uri.getHost(); //$NON-NLS-1$
int port = uri.getPort();
if (port > 0) {
}
}
+ private void updateSslVerifyUser(boolean value) {
+ FileBasedConfig userConfig = SystemReader.getInstance()
+ .openUserConfig(null, FS.DETECTED);
+ try {
+ userConfig.load();
+ updateSslVerify(userConfig, value);
+ } catch (IOException | ConfigInvalidException e) {
+ // Log it, but otherwise ignore here.
+ LOG.error(MessageFormat.format(JGitText.get().userConfigFileInvalid,
+ userConfig.getFile().getAbsolutePath(), e));
+ }
+ }
+
private URIish redirect(String location, String checkFor, int redirects)
throws TransportException {
if (location == null || location.isEmpty()) {