bug 11262: validate public key before processing it

status 11262: resolved fixed
This commit is contained in:
alena 2011-08-29 11:06:00 -07:00
parent a7da152b3d
commit 05478b26f6
1 changed files with 7 additions and 4 deletions

View File

@ -18,16 +18,16 @@
package com.cloud.utils.ssh;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair;
import com.jcraft.jsch.JSch;
import java.io.ByteArrayOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.codec.binary.Base64;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.KeyPair;
public class SSHKeysHelper {
private KeyPair keyPair;
@ -56,6 +56,9 @@ public class SSHKeysHelper {
public static String getPublicKeyFingerprint(String publicKey) {
String key[] = publicKey.split(" ");
if (key.length < 2) {
throw new RuntimeException("Incorrect public key is passed in");
}
byte[] keyBytes = Base64.decodeBase64(key[1]);
MessageDigest md5 = null;