Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all 3862 articles
Browse latest View live

How to upload a list of selected files in a listview

$
0
0

This question was converted from this comment of another question.

I am trying to use your software that I intend to buy... Currently I am trying to upload a list of selected files as in your example "FtpWinFormClient_CS" :
"await _ftp.UploadAsync(path, ".", TraversalMode.Recursive, TransferMethod.Copy, ActionOnExistingFiles.ThrowException);" ,
But this method takes only file by file.

Here is my code :

List<String> FilesList = new List<String>();
if (listLocal.SelectedItems.Count > 0)
    foreach (ListViewItem item in listLocal.SelectedItems)
    {
        string path = Path.Combine(_localPath, item.Text);
        FilesList.Add(path);
    }
string combindedString = string.Join(",", FilesList);
//MessageBox.Show(combindedString);
await _ftp.UploadAsync(combindedString, ".", TraversalMode.Recursive, TransferMethod.Copy, ActionOnExistingFiles.ThrowException);

So the question is how to upload a list of selected files in a listview

In advance, thank you for your answer !


Answered: header folding

$
0
0

The header folding is already implemented. You can try it for yourself by saving a MailMessage with long header, then look into produced data.

I think the problem "Headers too large" is caused by length of the unfolded header itself. So, you have 2 possibilities:

  1. Don't include so many recipients into mail headers. Correct me if I am wrong, but if you send an e-mail to thousands of recipients, you don't want to share addresses of all recipients between each other.

  2. Save space by omitting recipient's display name (just include only SMTP address). This will not solve the issue, but increase the limit of recipient count.

SFTP connection fails - Negotiation failed. The client and the server have no common key exchange algorithm

$
0
0

The full error message is:
Negotiation failed. The client and the server have no common key exchange algorithm. Server supports 'diffie-hellman-group1-sha1' which is weak and not enabled at the client.

How do I enable 'diffie-hellman-group1-sha1' ?

Rebex.Zip + NGen

$
0
0

Hi,

i bought your Zip component and get lots of warnings when ngenning like:

Warning: System.TypeLoadException: Could not load type 'Rebex.IO.EU' from assembly 'Rebex.Common, Version=2.0.6249.0, Culture=neutral, PublicKeyToken=1c4638788972655d'. while resolving 0x200002c - Rebex.IO.Compression.GNW.

Is this because i have a trial version of some other component of yours parallel installed?

Regards
Martin

Answered: SFTP connection fails - Negotiation failed. The client and the server have no common key exchange algorithm

$
0
0

This legacy algorithm can be enabled using Sftp object's Settings.SshParameters.KeyExchangeAlgorithms property:

var client = new Sftp();
client.Settings.SshParameters.KeyExchangeAlgorithms |= SshKeyExchangeAlgorithm.DiffieHellmanGroup1SHA1;
client.Connect(serverName);
...

For additional information, see SSH ciphers and Setting connection options.

Also, please be aware that the diffie-hellman-group1-sha1 cipher is not secure.

Wide Range Isn't Measured In Millions

$
0
0
Your kids are headed towards university. How do you want to pay for it all? You're really losing sleep over that concern. You aren't rich by any gold marketstretch associated with imagination, however think you have far too much cash to be eligible for financial aid. Listed here is a tip: that assumption will set you back big-time.

Rebex.Zip + NGen

$
0
0

Hi,

i bought your Zip component and get lots of warnings when ngenning like:

Warning: System.TypeLoadException: Could not load type 'Rebex.IO.EU' from assembly 'Rebex.Common, Version=2.0.6249.0, Culture=neutral, PublicKeyToken=1c4638788972655d'. while resolving 0x200002c - Rebex.IO.Compression.GNW.

Is this because i have a trial version of some other component of yours parallel installed?

Regards
Martin

Getting error while trying to login SFTP with username and privatekey?

$
0
0

Hi,

I am using rebex dll versision 2.0.5584.0 for SFTP conncetion. I am successfully login with username and password. But when I try to login with username and privateKey I am getting the below exception.

No suitable authentication method is supported. Supported methods: 'password,keyboard-interactive'.

Please below code:

SshPrivateKey privateKey = null;
privateKey = new SshPrivateKey(ppkFilename, password);
var sftp = new Sftp();
sftp.Connect(hostName);
ftp.Login(username, privateKey); //Here I am getting error.

I am using Rebex Tiny SFTP Server v.1.03.
Please help.


Rebex.Zip + NGen

$
0
0

Hi,

i bought your Zip component and get lots of warnings when ngenning like:

Warning: System.TypeLoadException: Could not load type 'Rebex.IO.EU' from assembly 'Rebex.Common, Version=2.0.6249.0, Culture=neutral, PublicKeyToken=1c4638788972655d'. while resolving 0x200002c - Rebex.IO.Compression.GNW.

Is this because i have a trial version of some other component of yours parallel installed?

Regards
Martin

Answered: Getting error while trying to login SFTP with username and privatekey?

$
0
0

It seems that the server has Public key authentication disabled.

In case of Rebex Tiny SFTP Server you can enable Public key authentication as follows:

1) In "RebexTinySftpServer.exe.config" file, specify value for userPublicKeyDir key. E.g.

<add key="userPublicKeyDir" value="keys"/>

2) Create specified folder keys in server's running directory.
3) Generate private key and save both private and public keys at the disk. Using Rebex component like this:

var pk = SshPrivateKey.Generate();
pk.Save("user1.pri", "password", SshPrivateKeyFormat.OpenSsh);
pk.SavePublicKey("user1.pub", SshPublicKeyFormat.Ssh2Base64);

4) Copy "user1.pub" file into "keys" directory created in step 2.
5) Start the server, you should see in log message like this: "Public key authentication enabled."

Now the server has Public key authentication enabled and you should be able to authenticate using "user1.pri" file created in step 3.

Answered: Is the IMAP client multi threaded

$
0
0

No, it is not possible. Sorry.

If you want to download multiple messages concurrently, please use more instances of Imap class.

Rebex HTTPS - accessing the request object from ValidatingCertificate event handler

$
0
0

In our application, we do certificate pinning usign custom certificate validation, and would need to replace the ICertificatePolicy.CheckValidationResult with the ValidatingCertificate event handler. Part of our logic needs to have access to the request object (url and headers) to determine if the certificate is valid or not. (At a high level, it needs to make a call to determine if the current client is configured to allow additional certificates, so that call needs a more relaxed certification validation logic).

Is there any way to access the WebRequest instance through the SslCertificateValidationEventArgs, or any other way ?

Thanks.

Subha Tarafdar.

Limit search results to a limit but only include items that don't have the deleted flag set

$
0
0

Is there a way to do a message search that limits the returned items to 500 items but searches for a flag being set? Basically I want to pull messages that don't have the delete flag set but not all of them at once? I plan on later going back and purging the messages. Purge takes a ton of resources and is slowing down the process significantly so I figure if I can do it afterwards.

Thanks
Nick

Unable to upload files to a specified SFTP location

$
0
0

My Code(few data are intentionally changed as "xxx.." for security reason ):-

public void SFtp_Connect()
{

        Sftp sftp = new Sftp();
        //sftp.Connect("xxx.xxx.x.xx", 22);
        //sftp.Login("xxx", "xxx");

        ////string sourceFilePath = @"C:\testFile\";
        //string sourceFilePath = @"C:\test_ftp\ExportList";
        //string targetPath = @"Test_Sftp";
        //string targetFilename = "";

        //sftp.Connect("xxx.xxx.com", 22);
        //sftp.Login("xxx", "xxx");

        sftp.Connect("xx.xxx.xx.xx", 22);
        sftp.Login("xxx", "xxx");

        string sourceFilePath = @"C:\Test\ExportList";
        string targetPath = @"/out/reports";
        string targetFilename = "";

        try
        {

            foreach (string UploadFile in Files)
            {
                //if (!sftp.DirectoryExists(targetPath))
                    //sftp.CreateDirectory(targetPath);

                sourceFilePath = sourceFilePath + "\\" + UploadFile;
                targetFilename = targetFilename + UploadFile;

                sftp.GetFile(sourceFilePath, UploadFile);                    
                //sftp.PutFile(sourceFilePath, targetPath + "/" + targetFilename);                   
            }
        }
        catch (Exception e)
        {
            throw e;
        }

        sftp.Disconnect();
    }

Error I got :-

2/23/2017 2:49:47 PM : Error on load, Error: Error while sending packet.. Inner Exception:Rebex.Net.SshException: Error while sending packet. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Rebex.Net.ProxySocket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Rebex.Net.SshSession.clmbOg(BBdsJfZ , Boolean )
--- End of inner exception stack trace ---
at Rebex.Net.SshSession.clmbOg(BBdsJfZ , Boolean )
at Rebex.Net.SshSession.CgoKrJZ()
at Rebex.Net.SshSession.cCIjvV(String , String , SshPrivateKey , SshGssApiCredentials )
at Rebex.Net.SshSession.Authenticate(String userName, String password, SshPrivateKey privateKey)
at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey). StackTrace: at Rebex.Net.Sftp.Login(String userName, String password, SshPrivateKey privateKey)
at xxx.Form1.SFtpConnectxxx() in d:\Projects\xxx\xxx\xxx\Form1.cs:line 216
at xxx.Form1.Form1_Load(Object sender, EventArgs e) in d:\Projects\xxx\xxx\xxx\Form1.cs:line 103

Answered: Rebex HTTPS - accessing the request object from ValidatingCertificate event handler

$
0
0

Actually, this sounds a little weird for us. The TLS/SSL layer is absolutely independent from HTTP protocol. You can use it for securing other protocols such as FTP. So interlink certificate validation with a WebRequest is little weird.

Also, the TLS/SSL session is created on server name (domain) basis, not URL basis. This means that subsequent requests for same server name (domain) doesn't require creating new TLS/SSL session (and certificate validation). Please see following sample code:

var creator = new HttpRequestCreator();
creator.ValidatingCertificate += (s, e) =>
{
    Console.WriteLine("Validating certificate for server: '{0}', IP: '{1}'.", e.ServerName, e.Socket.RemoteEndPoint);
    e.Accept();
};

string[] urls = 
{ 
    "https://rebex.net/sftp.net", // rebex.net
    "https://rebex.net/zip.net", // rebex.net
    "https://www.rebex.net/sftp.net", // www.rebex.net
    "https://www.rebex.net/zip.net", // www.rebex.net
    "https://rebex.net/sftp.net" // rebex.net
};

foreach (var url in urls)
{
    Console.WriteLine("Requesting: {0}", url);
    var request = creator.Create(url);
    var response = request.GetResponse();
    response.Close();
}

And this is the output:

Requesting: https://rebex.net/sftp.net
Validating certificate for server: 'rebex.net', IP: '195.144.107.196:443'.
Requesting: https://rebex.net/zip.net
Requesting: https://www.rebex.net/sftp.net
Validating certificate for server: 'www.rebex.net', IP: '195.144.107.196:443'.
Requesting: https://www.rebex.net/zip.net
Requesting: https://rebex.net/sftp.net

As you can see, the certificate validation was required only two times. Once for 'rebex.net' server name and once for 'www.rebex.net' server name. All subsequent requests were associated with already established TLS/SSL sessions.

If you want to disable this behavior, you can set creator.Settings.SslSessionCacheEnabled = false. This will cause, the TLS/SSL session will be created and validated for each request again.

Now to your problem. If you really need WebRequest instance at time you are validating a certificate, I suggest you to associate created requests with HttpRequestCreator instance like this:

public class MyCreator : HttpRequestCreator
{
    // holds request based on server name
    public Dictionary<string, WebRequest> Requests = new Dictionary<string, WebRequest>();

    public new HttpRequest Create(string uriString)
    {
        var request = base.Create(uriString);
        if (request.RequestUri.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))
        {
            lock (Requests)
            {
                // save request for current server name
                Requests[request.RequestUri.Host] = request;
            }
        }
        return request;
    }
}

Then you can get instance of the last created WebRequest in ValidatingCertificate like this:

var creator = new MyCreator();
creator.ValidatingCertificate += (s, e) =>
{
    WebRequest request = creator.Requests[e.ServerName];
    Console.WriteLine("Validating certificate for server: '{0}', IP: '{1}'.", e.ServerName, e.Socket.RemoteEndPoint);
    Console.WriteLine("Validating URI: {0}", request.RequestUri);
    e.Accept();
};

Please note, that this code will work for sequential requests, but can fail for parallel requests.

If parallel requests are necessary, you can either add synchronization or simply create own HttpRequestCreator instance for each WebRequest. In second case, association between creator and request is unique, but TLS/SSL sessions cannot be shared.


SSH TerminalException: Cannot send data because the terminal is not bound to a channel

$
0
0

Hello,

One of our clients sometimes gets an error "Cannot send data because the terminal is not bound to a channel".
The error is thrown immediately when trying to send a text line to a remote host through the VirtualTerminal.

We are using the following code to start the terminal session:

var terminal = ssh.StartVirtualTerminal();

and then

terminal.SendToServer(commandStr); <-- This line sometimes fails!

Unfortunately the stack trace does not contain any useful information to identify possible reasons:

Rebex.TerminalEmulation.TerminalException: Cannot send data because the terminal is not bound to a channel.
at Rebex.TerminalEmulation.VirtualTerminal.SendToServer(String text)

Could you please point me out why this error occurs and how to deal with it?

Thanks in advance!

Answered: Limit search results to a limit but only include items that don't have the deleted flag set

$
0
0

Paging can be done like this:

int pageSize = 500;
for (int i = 1; i <= imap.CurrentFolder.TotalMessageCount; i += pageSize)
{
    var page = new ImapMessageSet();
    page.AddRange(i, i + pageSize - 1);

    var list = imap.Search(page, ImapListFields.UniqueId, ImapSearchParameter.Not(ImapSearchParameter.Deleted));
    // do something with messages ...
}

Please note this paging limits input collection, not output collection. It means that if you have pageSize = 500, the resulting list will contain 500 or less messages.

How to convert linked resources to attachments

$
0
0

Hi,

I am trying to show inbound email in an application wherein inline (embedded) image content wanted to show as an attachments.

So here need to convert message.Resources content to AttachmentCollection.

here is an attachment collection in which Resouces content we have to add.

could you help me in the casting Resources into AttachmentCollection. (LinkedResource to Attachment)

Rebex.EWS.StoreMessage stores messages on exchange server in editable format

$
0
0

Hello
I am trying to put eml messages onto Exchange server, using Rebex.EWS, but messages received are in editable format, like draft messages. Below is the code I use

protected void SendMessage(byte[] emlData){
Rebex.Mail.MailMessage mailMsg = new Rebex.Mail.MailMessage();
mailMsg.Load(emlData);
//I tried to fix it with X-Unsent header, but it didn't work
messageMime.Headers.Add("X-Unsent", "0");
ews.StoreMessage(config.Folder.Id, mailMsg);
}

Thank you

Is possible to do the Xml signature with the new version

$
0
0

I need to create XML signature file with compactFramework (as xmlsec does using C language and openSSL).
Is it possible with you library do this operation?
Thanks

Viewing all 3862 articles
Browse latest View live