Skip to content

Commit 6161f86

Browse files
ptzieglerakurtakov
authored andcommitted
Make org.eclipse.jsch.ui compatible with modern JSch versions
This is a continuation of 07f86ab. On modern JSch versions, the call to `setPassphrase(...)` will always throw an `UnsupportedOperationException`. Instead of using this deprecated method (which is already deprecated in JSch 0.1.55), the pass-phrase should be passed as an additional argument when calling `writePrivateKey(...)`. To reproduce: Run the Eclipse IDE with e.g. `com.github.mwiede.jsch` in version 2.27.7. Then, open the SSH2 preference page, create a new RSA-key and then save the private key.
1 parent 1fa3c16 commit 6161f86

File tree

1 file changed

+3
-4
lines changed
  • team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference

1 file changed

+3
-4
lines changed

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -742,8 +742,6 @@ public void widgetSelected(SelectionEvent e){
742742
}
743743
}
744744

745-
kpair.setPassphrase(pass);
746-
747745
String home=ssh2HomeText.getText();
748746

749747
File _home=new File(home);
@@ -777,7 +775,8 @@ public void widgetSelected(SelectionEvent e){
777775

778776
boolean ok=true;
779777
try{
780-
kpair.writePrivateKey(file);
778+
byte[] passBytes = pass.isEmpty() ? null : pass.getBytes();
779+
kpair.writePrivateKey(file, passBytes);
781780
kpair.writePublicKey(file+".pub", kpairComment); //$NON-NLS-1$
782781
}
783782
catch(Exception ee){

0 commit comments

Comments
 (0)