/// <summary> /// Read SSH2 private key parameters. /// </summary> /// <param name="passphrase">passphrase for decrypt the key file</param> /// <param name="keyPair">key pair is set</param> /// <param name="comment">comment is set. empty if it didn't exist</param> /// <exception cref="SSHException">failed to parse</exception> public void LoadSSH2PrivateKey( string passphrase, out KeyPair keyPair, out string comment) { PrivateKeyFileFormat format = ProbeFormat(); ISSH2PrivateKeyLoader loader; if (format == PrivateKeyFileFormat.SSH2_SSHCOM) { loader = new SSHComPrivateKeyLoader(keyFile, keyFilePath); } else if (format == PrivateKeyFileFormat.SSH2_OPENSSH) { loader = new OpenSSHPrivateKeyLoader(keyFile, keyFilePath); } else if (format == PrivateKeyFileFormat.SSH2_PUTTY) { loader = new PuTTYPrivateKeyLoader(keyFile, keyFilePath); } else { throw new SSHException(Strings.GetString("UnsupportedPrivateKeyFormat")); } loader.Load(passphrase, out keyPair, out comment); }
/// <summary> /// Read SSH2 private key parameters. /// </summary> /// <param name="passphrase">passphrase for decrypt the key file</param> /// <param name="keyPair">key pair is set</param> /// <param name="comment">comment is set. empty if it didn't exist</param> /// <exception cref="SSHException">failed to parse</exception> public void LoadSSH2PrivateKey( string passphrase, out KeyPair keyPair, out string comment) { PrivateKeyFileFormat format = ProbeFormat(); ISSH2PrivateKeyLoader loader; if (format == PrivateKeyFileFormat.SSH2_SSHCOM) loader = new SSHComPrivateKeyLoader(keyFile, keyFilePath); else if (format == PrivateKeyFileFormat.SSH2_OPENSSH) loader = new OpenSSHPrivateKeyLoader(keyFile, keyFilePath); else if (format == PrivateKeyFileFormat.SSH2_PUTTY) loader = new PuTTYPrivateKeyLoader(keyFile, keyFilePath); else throw new SSHException(Strings.GetString("UnsupportedPrivateKeyFormat")); loader.Load(passphrase, out keyPair, out comment); }