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

Answered: Rebex Http type load exception

$
0
0

This seems to be a limitation of our installation process.

When you combine Full assemblies and Trial assemblies, the Trial ones will throw the mentioned exception.

The workaround is to install Full and Trial assemblies into separate folders e.g.:

  • "c:\Program Files (x86)\Rebex Components 2017 R1" for Full assemblies
  • "c:\Program Files (x86)\Rebex Components 2017 R1 Trial" for Trial assemblies

Rebex.Net.Sftp.ConnectAsync is not completely asynchronous?

$
0
0

Does the "ConnectAsync" method that is in Rebex.Net.Sftp class work completely asynchronously? I've tried to limit thread pool maximum worker threads to 10 and started 10 parallel executions of "ConnectAsync" method. In this case all the threads were blocked in Rebex.Net.ProxySocket.IR method until the timeout occurred. However if I decrease parallel executions to 9, all of them are processed successfully within few seconds.

It's critical issue for us, any help will be appreciated!

Answered: Signing/verifying a file with a PEM file

$
0
0

Lukas, thanks for the quick and detailed response!

When I run your code on a desktop VB.net program, it outputs a binary signature file with the correct number of bytes (yeah!), but when I run the verification routine it fails.

Do I need to run an ECC plugin for my desktop app?

Yes, my private key is an elliptic curve private key, it was created using this command:

openssl ecparam -out priv.pem -noout -name secp521r1 -genkey

I'm unsure if this is the same as a NIST P-521 curve key.

Note I'm using the Rebex.Security.dll (2017 trial), but the other Rebex dlls are from a purchased 2016 R3 release. I referenced the files in
C:\Program Files (x86)\Rebex Components 2016 R3\bin\net-2.0

Do all the dlls need to be from the same release?

Switching to my mobile app:

When run it displays "Elliptic curve algorithms need a plugin on this platform". It sounds like I didn't install the plugin correctly. Here's how I installed it:

  • Downloaded the ECC plugins from your link
  • Added project references to

    • netcf-2.0\Rebex.Castle.dll
    • netcf-2.0\Rebex.Curve25519.dll
  • Copied these 2 dlls to mobile device's app folder, which already had Rebex.Sftp.dll, Rebex.Networking.dll, Rebex.Common.dll, Rebex.Security.dll (2017 trial) .
    Note: the other Rebex dlls are from a purchased 2016 R3 release.

At the top of my app I import:

Imports Rebex.Security.Cryptography
Imports Rebex.Security.Cryptography.EllipticCurveAlgorithm

I don't know how to convert this sample C code on the plugin page to VB:

// import NIST and Brainpool curves
AsymmetricKeyAlgorithm.Register(EllipticCurveAlgorithm.Create);

I added this to CreateEncodedSignature():

AsymmetricKeyAlgorithm.Register(EllipticCurveAlgorithm.Create)

But this gives a compile error:

  • error BC30455: Argument not specified for parameter 'algName' of 'Public Shared Function Create(algName As String) As Rebex.Security.Cryptography.EllipticCurveAlgorithm'.

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

Rebex SFTP: Key exchange failed. Server signature is not valid.

$
0
0

Hi, we connect to an external SFTP server with Rebex. Today after the server was upgraded CrushFtp version 3 to version 7.7, we start to receive the following exceptions. Any idea what the error mean and how to fix? Thanks.

2016-11-14 11:46:26.081 DEBUG Sftp(1)[1] SSH: Validating signature.
2016-11-14 11:46:26.082 DEBUG Sftp(1)[1] SSH: Negotiation failed: Rebex.Net.SshException: Key exchange failed. Server signature is not valid. ---> Rebex.Net.SshException: Server signature is not valid.
   at Rebex.Net.OGB.L(Byte[] A, Byte[] B, Byte[] C, SshPublicKey& D)
   at Rebex.Net.PGB.D(SshSession A, Byte[] B, Byte[] C, Byte[] D, Byte[] I, Byte[]& J, Byte[]& L, SshPublicKey& M)
   at Rebex.Net.SshSession.BZ(Byte[] A)
   --- End of inner exception stack trace ---
   at Rebex.Net.SshSession.BZ(Byte[] A)
2016-11-14 11:46:26.082 ERROR Sftp(1)[1] SSH: Rebex.Net.SshException: Key exchange failed. Server signature is not valid. ---> Rebex.Net.SshException: Server signature is not valid.
   at Rebex.Net.OGB.L(Byte[] A, Byte[] B, Byte[] C, SshPublicKey& D)
   at Rebex.Net.PGB.D(SshSession A, Byte[] B, Byte[] C, Byte[] D, Byte[] I, Byte[]& J, Byte[]& L, SshPublicKey& M)
   at Rebex.Net.SshSession.BZ(Byte[] A)
   --- End of inner exception stack trace ---
   at Rebex.Net.SshSession.BZ(Byte[] A)
   at Rebex.Net.SshSession.AZ()
   at Rebex.Net.SshSession.Negotiate()
2016-11-14 11:46:26.082 ERROR Sftp(1)[1] Info: Rebex.Net.SshException: Key exchange failed. Server signature is not valid. ---> Rebex.Net.SshException: Server signature is not valid.
   at Rebex.Net.OGB.L(Byte[] A, Byte[] B, Byte[] C, SshPublicKey& D)
   at Rebex.Net.PGB.D(SshSession A, Byte[] B, Byte[] C, Byte[] D, Byte[] I, Byte[]& J, Byte[]& L, SshPublicKey& M)
   at Rebex.Net.SshSession.BZ(Byte[] A)
   --- End of inner exception stack trace ---
   at Rebex.Net.SshSession.BZ(Byte[] A)
   at Rebex.Net.SshSession.AZ()
   at Rebex.Net.SshSession.Negotiate()
   at Rebex.Net.Sftp.QNB.BZ(BNB A)
   at Rebex.Net.Sftp.XM(String A, Int32 B, SshParameters C, BNB D)
2016-11-14 11:46:26.164 ERROR Sftp(1)[1] Info: System.InvalidOperationException: Not connected to the server.
   at Rebex.Net.Sftp.FP(String A, String B, SshPrivateKey C, BNB D)

Answered: Rebex.Zip + NGen

$
0
0

Self answer my question: It's due to parallel installation of trial and licensed components!

any special configuration required for Rebex Mail for ASP.NET?

$
0
0

Everything was working fine on my development PC. So I installed the ASP.NET app on the IIS server, and there it doesn't work.

I've ensured that ports 25 and 465 are open for inbound/outbound traffic on the hardware firewall. Windows software firewall is OFF.

Network admins say they see no outbound traffic on port 465.

Any other basic configuration steps required? Does Rebex require any file permissions?

Answered: How to upload a list of selected files in a listview

$
0
0

The ftp.UploadAsync method can take two kind of parameters:

  1. A string which represents path to a file or a directory.
  2. The FileSet object, which can be used to define multiple files and directories.

If you want to simply upload single file or directory asynchronously, call the Upload method like this:

// localPath is path to single file or directory
await _ftp.UploadAsync(localPath, ".", TraversalMode.Recursive, TransferMethod.Copy, ActionOnExistingFiles.ThrowException);

If you want to upload multiple files and/or directories from one specific directory (I think this is your case), you can do it like this:

if (listLocal.SelectedItems.Count > 0)
{
    // initialize FileSet with current directory
    FileSet set = new FileSet(_localPath);
    foreach (ListViewItem item in listLocal.SelectedItems)
    {
        // include selected items to FileSet
        if (item.Text != "."&& item.Text != "..")
            set.Include(item.Text);
    }
    // upload specified FileSet
    await _ftp.UploadAsync(set, ".", TransferMethod.Copy, ActionOnExistingFiles.ThrowException);
}

Error for Outlook Oauth2

$
0
0

OAuth20 authentication is failing for Gmail.

Below is the smtpException I am getting:
Rebex.Net.SmtpException: OAuth failed: OAuth authentication failed due to Invalid token. Code -2147184118

For gmail, I'd given full scope - mail.google.com/ but nothing is mentioned for outlook. This is what I've given as scope for outlook - openid+offline_access+profile+https:%2f%2foutlook.office.com%2fmail.send

Below is the code snippet:

try{
        Smtp client = new Smtp();
        client.Connect("smtp-mail.outlook.com", SslMode.Explicit);

        // prepare token
        string pattern = string.Format("user={0}{1}auth=Bearer {2}{1}{1}", userEmailId, '\x1', accessToken);
        string token = Convert.ToBase64String(Encoding.ASCII.GetBytes(pattern));

        client.Login(token, SmtpAuthentication.OAuth20);
    }
    catch(SmtpException ex)
    {}
}

Kindly let me know if there is anything that I'm doing wrong here. I could make this work with Gmail. I've also tried to use IMAP instead of SMTP for outlook but no result.

Regards
Mrinal

Answered: SFTP GetList - Duplicate Filename on Server

$
0
0

You are right - when Sftp.GetList encounters duplicate filename, it silently ignores it. The main reason for this is the Dictionary-like nature of SftpItemCollection class - a filename currently acts as a key and can be used as an indexer.

Ignoring duplicate filenames is not entirely desirable, but there are not many alternatives:
a) fail when duplicate filename is encountered
b) modify SftpItemColection to allow duplicate filenames

We originally did (a), but some of our clients actually encountered duplicate filenames and complained. Switching to (b) would be problematic as well. It would make our API harder to use (not a good way to address a rather rare server bug). Users don't expect duplicate files and there would be no way to distinguish one from the other when working with them through the SFTP protocol. Instead, we modified the parser to simply ignore duplicate filenames six years ago.

This said, it's true that silently ignoring this server-side issue might be undesirable in many scenarios. In the next release, we will log a warning into the communication log when a duplicate filename is encountered, which will lower the chance that this will get unnoticed. We might even add an option that makes the parser fail in this case (if there is actually demand for that).

Which behavior would you prefer?

TinySftpServer throws does not load user public key

$
0
0

I've downloaded TinySftpServer C# sample, and when the server starts and tries to load users public keys, which are open ssh, I get an error:
User public key 'C:\Keys\public\pubOpenSsh.key' could not be loaded: Data too long.

Please advise.

Answered: Signing/verifying a file with a PEM file

$
0
0

In 2017 R2, we will introduce a new API that makes it much easier to create or verify OpenSSL signatures. If anyone would like to try a beta, please let us know at support@rebex.net

Creating a signature:

' load private key
Dim key = New PrivateKeyInfo()
key.Load("priv.pem", "secretpassword")

' load content to sign
Dim content As Byte() = File.ReadAllBytes("filetosign")

' create signature
Dim signature As Byte()
Using alg = New AsymmetricKeyAlgorithm()
    ' import the key
    alg.ImportKey(key)

    ' specify signature parameters
    Dim parameters = New SignatureParameters()
    parameters.Format = SignatureFormat.Pkcs

    ' create signature
    signature = alg.SignMessage(content, parameters)
End Using

' save the signature
File.WriteAllBytes("sign.sha", signature)

Verifying a signature:

' load public key
Dim key = New PublicKeyInfo()
key.Load("pub.pem")

' load content to sign
Dim content As Byte() = File.ReadAllBytes("filetosign")

' load signature
Dim signature As Byte() = File.ReadAllBytes("sign.sha")

' verify signature
Dim valid As Boolean
Using alg = New AsymmetricKeyAlgorithm()
    ' import the key
    alg.ImportKey(key)

    Dim parameters = New SignatureParameters()
    parameters.Format = SignatureFormat.Pkcs

    valid = alg.VerifyMessage(content, signature, parameters)
End Using

' show the result
Console.WriteLine("Valid: {0}", valid)

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

SSH. Rebex.TerminalEmulation.Scripting and ESC[nD sequence support.

$
0
0

Hello. I have a question about Scripting mechanism.

I got the following result after executing SSH command.

2016-11-18 13:31:15.630 VERBOSE Ssh(1)[10] Info: Received data: 
 0000 |1B-5B-34-32-44-20-20-20 20-20-20-20-20-20-20-20| .[42D           
 0010 |20-20-20-20-20-20-20-20 20-20-20-20-20-20-20-20|                 
 0020 |20-20-20-20-20-20-20-20 20-20-20-20-20-20-20-1B|                .
 0030 |5B-34-32-44                                    | [42D
2016-11-18 13:31:15.630 VERBOSE VirtualTerminal(0)[10] Scripting:     WaitFor: polling data for max 50 ms.
2016-11-18 13:31:15.644 VERBOSE Ssh(1)[12] SSH: Received packet SSH_MSG_CHANNEL_DATA (51 bytes).
 0000 |5E-00-00-00-00-00-00-00 2A-20-6E-74-70-2D-73-65| ^.......* ntp-se
 0010 |72-76-69-63-65-20-75-6E 69-63-61-73-74-2D-73-65| rvice unicast-se
 0020 |72-76-65-72-20-31-39-32 2E-31-36-38-2E-31-30-30| rver 192.168.100
 0030 |2E-32-38                                       | .28

Scripting.ReceivedData return:

"                                           ntp-service unicast-server 192.168.100.28"

or

"42D                                          42D ntp-service unicast-server 192.168.100.28"

I tried to use all terminal types (Ansi, Wyse60, Pick, VT52).

I expect to see:

" ntp-service unicast-server 192.168.100.28"

(all without double quotes)

Does the Scripting mechanism support "1B-5B-xx-xx-44" (ESC[nD) sequence? How i can properly use it?

Answered: Post file on Windows CE 5 with HTTPS/SSL and SHA-2 certificates.

$
0
0

Rebex HTTPS for .NET library has been officially released in February 2017. It will enable you to use TLS 1.1 and TLS 1.2 with SHA-2 certificates on legacy platforms including Windows Mobile/.NET Compact Framework and old Windows systems like Windows XP.
We are making legacy platforms secure again!


Authenticate to Yahoo and Outlook.com email servers with OAuth 2.0

$
0
0

I am trying to authenticate to Yahoo and Outlook (live.com) mail servers with OAuth 2.0.

How can I do this with Rebex Secure Mail component?

Answered: Unable to upload files to a specified SFTP location

$
0
0

Does the error occurs every time you try to login or occasionally?

Can you please post here or send us (to support@rebex.net) the communication log for analysis?

It can be created like this:

sftp.LogWriter = new Rebex.FileLogWriter(@"c:\Test\log.txt", Rebex.LogLevel.Debug);

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!

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

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

$
0
0

It is a little bit misleading error message. It is true, that the terminal is not bound to a channel, however the real cause is probably that the terminal was unbound due to loss of connection.

The terminal is not bound to a channel in 4 cases:

  1. a new instance of terminal, which was never bound
  2. an instance on which Unbind method was just called
  3. an instance on which Dispose method was called
  4. an instance, which underlying channel was undound due to connection loss

From your description, we can eliminate point 1 (ssh.StartVirtualTerminal() creates bound terminal).

If you are sure that you didn't call Unbind or Dispose methods before you call SendToServer method, the last possible explanation is point 4.

Basically, it can arises in 3 situations:

  1. connection close was requested by client e.g. by issuing exit command
  2. connection was close forcibly by server e.g. the server encountered an error and closed the existing connection
  3. connection was interrupted due to network failure

To detect any of the above connection closures please use the VirtualTerminal.Disconnected event.

However, I improved exception message to better describe the situation.

If you have doubts about the cause of error in your case, please send us the Debug log of your communication (to support@rebex.net). I will analyze it for you.

Viewing all 3862 articles
Browse latest View live