New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatibility with legacy jsch as used by jgit #85
Comments
Hi @ST-DDT, Please see #43 for a potential workaround. You may also want to open a bug with the Eclipse team, as their decision to unconditionally perform Thanks, |
Sure, I can open one, but can you give me a little bit of context what these values refer to and whats the difference between them? |
Hi @ST-DDT,
The quickest way for them to fix it would probably be to simply check whether the config items they attempt to add are already present or not:
Also, I'm not sure if they would be interested in changing their JSch dependency long-term to this particular fork, since the original JSch from JCraft is unmaintained these days? I'd be happy (and I'm sure @mwiede would be as well) to collaborate with them on any changes we could make in this fork that could improve their integration with JSch: I suspect this code was added by them to workaround a deficiency in the original JSch. Thanks, |
Hi @ST-DDT, On an unrelated note, I also noticed that you had the following dependencies:
Are you aware of how we directly integrated support for Thanks, |
No, I wasn't. I have searched for agentproxy packages in the jar, but since I couldn't find any, I kept my original ssh-agent-glue code. |
I tested with the libraries as used in the commit, but I was unable to make it work with windows 10 and java 11 64bit. The problem might be the use of |
Hi @ST-DDT, I've only tested on Linux & macOS, so I'm not sure if there could be issues on Windows. Thanks, |
For future reference, the windows implementation uses the pageant connector (for me).
Caused by: java.lang.IllegalAccessException: Class com.sun.jna.Structure can not access a member of class com.jcraft.jsch.PageantConnector$COPYDATASTRUCT64 with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:102)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:296)
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:288)
at java.lang.reflect.Field.get(Field.java:390)
at com.sun.jna.Structure.getFieldValue(Structure.java:650)
... 101 more EDIT3: The |
Here is my jgit + jsch + agent bridge code so far: /**
* Tries to setup the ssh agent connection.
*
* @return True, if the agent was configured successfully. False, if the setup failed or was not
* attempted.
*/
public static boolean trySetupSSHAgent() {
try {
final AgentConnector connector = tryGetAgentConnector();
if (connector == null) {
return false; // Not attempted
}
final IdentityRepository identityRepository = new AgentIdentityRepository(connector);
final JschConfigSessionFactory factory = new JschConfigSessionFactory() {
@Override
protected JSch createDefaultJSch(final FS fs) throws JSchException {
final JSch jsch = super.createDefaultJSch(fs);
jsch.setIdentityRepository(identityRepository);
return jsch;
}
};
SshSessionFactory.setInstance(factory);
return true; // Success
} catch (final Exception e) {
if (LOGGER.isDebugEnabled()) {
LOGGER.info("Failed to setup ssh agent connector", e);
} else {
LOGGER.info("Failed to setup ssh agent connector");
}
return false; // Failed
}
}
/**
* Tries to get an available agent connector.
*
* @return An available agent connector or null.
*/
private static AgentConnector tryGetAgentConnector() {
AgentConnector connector = callOrNull(SSHAgentConnector::new, "SSHAgentConnector");
if (connector != null && connector.isAvailable()) {
return connector;
}
connector = callOrNull(PageantConnector::new, "PageantConnector");
if (connector != null && connector.isAvailable()) {
return connector;
}
return null;
}
/**
* Calls the given callable. Returning the result on success or {@code null} on error.
*
* @param <T> The type of the result.
* @param callable The callable to call.
* @param hint The hint for the log message.
* @return The result of the callable or null.
*/
private static <T> T callOrNull(final Callable<T> callable, final String hint) {
try {
return callable.call();
} catch (final Exception e) {
LOGGER.debug("Failed to call {} (Can usually be ignored)", hint, e);
return null;
}
} |
Yes, it does. After the PR is merged I will build the project locally and test again. Then I will probably propose a convenience method to |
Hi @ST-DDT , That is excellent to hear! Thanks, |
Yes, that was exactly my intention. Using it is optional, so it won't limit the user to one or the other, but help them to get started and show an example "implementation", that they then can adapt to their needs. My idea is to implement it similar to my above example: Trying them one by one (Starting with the unix dmonain sockets). IIRC the jsch.agentproxy.jsch did exactly that.
I can try, if the result is positive, then I'm sure that it works. But if it is negative, I'm not sure whether it is related to my untested ssh-agent setup, or the path used to access it, or the the java code. |
Ok, that sounds like it would be workable.
Yes, any test results you could provide from a Windows environment would be great! Thanks, |
I just tested the pageant fix in v0.1.69 and it works as expected. I'll now contact jgit for a fix for: #85 (comment) |
Hi @ST-DDT, That is great to hear, thanks! Thanks, |
Update from JGit: |
closing this as it is solved. Somebody asked on Stackoverflow compare at https://stackoverflow.com/questions/73046450/spring-cloud-config-server-algorithm-negotiation-fail-problem |
I tried to replace the original jsch with this updated variant, but that caused an NPE.
This is caused by the following line: Source
In the original jsch version this was set to:
This version no longer sets these properties.
My dependencies:
Stacktrace
The text was updated successfully, but these errors were encountered: