Skip to content

Commit

Permalink
[FIXED JENKINS-44832] IAE under unknown conditions due to empty or nu…
Browse files Browse the repository at this point in the history
…ll list of preferred key algorithms.
  • Loading branch information
jglick committed Jun 13, 2017
1 parent 9726126 commit b9620ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/hudson/plugins/sshslaves/SSHLauncher.java
Expand Up @@ -793,7 +793,12 @@ public synchronized void launch(final SlaveComputer computer, final TaskListener
public Boolean call() throws InterruptedException {
Boolean rval = Boolean.FALSE;
try {
connection.setServerHostKeyAlgorithms(getSshHostKeyVerificationStrategyDefaulted().getPreferredKeyAlgorithms(computer));
String[] preferredKeyAlgorithms = getSshHostKeyVerificationStrategyDefaulted().getPreferredKeyAlgorithms(computer);
if (preferredKeyAlgorithms != null && preferredKeyAlgorithms.length > 0) { // JENKINS-44832
connection.setServerHostKeyAlgorithms(preferredKeyAlgorithms);
} else {
listener.getLogger().println("Warning: no key algorithms provided; JENKINS-42959 disabled");
}

openConnection(listener, computer);

Expand Down
Expand Up @@ -23,6 +23,8 @@
*/
package hudson.plugins.sshslaves.verifiers;

import com.trilead.ssh2.Connection;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.TaskListener;
Expand Down Expand Up @@ -56,6 +58,12 @@ public SshHostKeyVerificationStrategyDescriptor getDescriptor() {
*/
public abstract boolean verify(SlaveComputer computer, HostKey hostKey, TaskListener listener) throws Exception;

/**
* Provides a list of preferred key algorithms for this strategy and computer.
* @return a list of algorithms; empty or null lists will be ignored
* @see Connection#setServerHostKeyAlgorithms
*/
@CheckForNull
public String[] getPreferredKeyAlgorithms(SlaveComputer computer) throws IOException {
return TrileadVersionSupportManager.getTrileadSupport().getSupportedAlgorithms();
}
Expand Down

0 comments on commit b9620ee

Please sign in to comment.