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

SFTP server: long delay while connecting with full CPU load

$
0
0

Hi,

while evaluating Rebex File Server (SFTP), I see a long delay of about 70 seconds when a client connects. During this time, the SFTP server seems to take 100% of the CPU. After that, the connection succeeds and the CPU load goes back to normal.
The device is a PDA with ARM processor, Windows CE 6.0, .NET Compact Framework 3.5.

Here is the Log. The delay is between 16:13:47 and 16:15:01:

2016-11-02 16:12:44 INFO FileServer(1)[77332506] Server: Starting server.
2016-11-02 16:12:44 INFO FileServer(1)[77332506] Server: Listening for connections at 0.0.0.0:22.
2016-11-02 16:12:44 INFO FileServer(1)[77332506] Server: Server started.
2016-11-02 16:13:47 DEBUG FileServer(1)[95813678] Server: Accepted connection from 172.23.6.38:54792.
2016-11-02 16:13:47 INFO FileServer(1)[95813678] Server: Session 1: Started on connection from 172.23.6.38:54792.
2016-11-02 16:13:47 DEBUG FileServer(1)[95813678] SSH: Session 1: Local SSH version: SSH-2.0-RebexSSH_1.0.6083.0
2016-11-02 16:13:47 DEBUG FileServer(1)[93782146] SSH: Session 1: Remote SSH version: SSH-2.0-OpenSSH_7.3
2016-11-02 16:13:47 DEBUG FileServer(1)[93782146] SSH: Session 1: Performing algorithm negotiation and key exchange.
2016-11-02 16:13:47 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_KEXINIT (776 bytes).
2016-11-02 16:13:47 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_KEXINIT (1432 bytes).
2016-11-02 16:13:47 DEBUG FileServer(1)[95813678] SSH: Session 1: Performing key exchange using diffie-hellman-group-exchange-sha256 with ssh-rsa.
2016-11-02 16:13:47 VERBOSE FileServer(1)[93782146] SSH: Session 1: Received packet SSH_MSG_PACKET34 (24 bytes).
2016-11-02 16:13:47 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_KEXDH_REPLY (536 bytes).
2016-11-02 16:13:47 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_PACKET32 (272 bytes).
2016-11-02 16:15:01 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_PACKET33 (832 bytes).
2016-11-02 16:15:01 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_NEWKEYS (16 bytes).
2016-11-02 16:15:01 DEBUG FileServer(1)[95813678] SSH: Session 1: Current encryptor is aes128-ctr/hmac-sha2-256.
2016-11-02 16:15:01 VERBOSE FileServer(1)[93782146] SSH: Session 1: Received packet SSH_MSG_NEWKEYS (16 bytes).
2016-11-02 16:15:01 DEBUG FileServer(1)[93782146] SSH: Session 1: Current decryptor is aes128-ctr/hmac-sha2-256.
2016-11-02 16:15:01 DEBUG FileServer(1)[93782146] SSH: Session 1: Key exchange finished.
2016-11-02 16:15:02 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_SERVICE_REQUEST (64 bytes).
2016-11-02 16:15:02 DEBUG FileServer(1)[95813678] SSH: Session 1: Performing authentication.
2016-11-02 16:15:02 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_SERVICE_ACCEPT (64 bytes).
2016-11-02 16:15:02 VERBOSE FileServer(1)[93782146] SSH: Session 1: Received packet SSH_MSG_USERAUTH_REQUEST (80 bytes).
2016-11-02 16:15:02 DEBUG FileServer(1)[93782146] SSH: Session 1: Starting authentication as 'admin' for 'ssh-connection'.
2016-11-02 16:15:02 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_USERAUTH_FAILURE (80 bytes).
2016-11-02 16:15:02 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_USERAUTH_REQUEST (112 bytes).
2016-11-02 16:15:02 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_PACKET60 (80 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Received packet SSH_MSG_USERAUTH_INFO_RESPONSE (96 bytes).
2016-11-02 16:15:09 INFO FileServer(1)[93782146] Server: Session 1: Authentication for 'admin' succeeded.
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_USERAUTH_SUCCESS (48 bytes).
2016-11-02 16:15:09 DEBUG FileServer(1)[93782146] SSH: Session 1: Authenticated as 'admin' for 'ssh-connection'.
2016-11-02 16:15:09 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_CHANNEL_OPEN (80 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_OPEN_CONFIRMATION (64 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Received packet SSH_MSG_CHANNEL_REQUEST (80 bytes).
2016-11-02 16:15:09 DEBUG FileServer(1)[93782146] Server: Session 1: Starting SftpModule(1) subsystem.
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_WINDOW_ADJUST (64 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_SUCCESS (48 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_CHANNEL_DATA (64 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_IGNORE (48 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_DATA (112 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[96534662] SSH: Session 1: Received packet SSH_MSG_CHANNEL_DATA (64 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_IGNORE (48 bytes).
2016-11-02 16:15:09 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_DATA (80 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_CHANNEL_DATA (64 bytes).
2016-11-02 16:15:30 DEBUG SftpModule(1)[93782146] SFTP: Opening directory '/': success.
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_IGNORE (48 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_DATA (80 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[96534662] SSH: Session 1: Received packet SSH_MSG_CHANNEL_DATA (80 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_IGNORE (48 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_DATA (1328 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_CHANNEL_DATA (80 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_IGNORE (48 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_DATA (96 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[96534662] SSH: Session 1: Received packet SSH_MSG_CHANNEL_DATA (80 bytes).
2016-11-02 16:15:30 DEBUG SftpModule(1)[93782146] SFTP: Closing file '/': success.
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_IGNORE (48 bytes).
2016-11-02 16:15:30 VERBOSE FileServer(1)[93782146] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_DATA (80 bytes).
2016-11-02 16:15:34 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_CHANNEL_EOF (48 bytes).
2016-11-02 16:15:34 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_CHANNEL_CLOSE (48 bytes).
2016-11-02 16:15:34 VERBOSE FileServer(1)[93782146] SSH: Session 1: Received packet SSH_MSG_CHANNEL_CLOSE (48 bytes).
2016-11-02 16:15:34 VERBOSE FileServer(1)[95813678] SSH: Session 1: Received packet SSH_MSG_DISCONNECT (80 bytes).
2016-11-02 16:15:34 VERBOSE FileServer(1)[95813678] SSH: Session 1: Sent packet SSH_MSG_DISCONNECT (96 bytes).
2016-11-02 16:15:34 INFO FileServer(1)[95813678] SSH: Session 1: Connection close requested.

What's going on during this delay and what can be done to avoid it?

Thanks!


Answered: Compressed files with 7-zip 9.20 64-Bit on Ubuntu 16.04 TLS can not extracted

$
0
0

Hello Bernhard and thank you for the excellent report.

The only problem is ZipItem.ItemType identification. It is caused by VersionNeeded field which has value 778 (which is far greater than supported by Rebex = 45). If interested, see 4.4.3 version needed to extract (2 bytes).

However, there is no need to check this field in case of your ZIP file, because it specifies ZipItem.ItemType for each item using external file attributes (unix permissions in this case).

I have improved ZipItem.ItemType identification and I will send you full binaries in a moment to your email.

Also, we will discuss whether to add an option to force item extraction if unsupported feature is detected.

Smtp.ResolveDomainMx timeout

$
0
0

hello,
after calling Smtp.ResolveDomainMx, is there a way to distinguish between:
- a non existing domain,
- an existing domain for which a timeout occurred during DNS lookup in the upstream DNS server ? assuming a shorter timeout for the upstream DNS server than for the ResolveDomainMx call.

thanks.

Invalid TNEF message.

$
0
0

Hi Rebex Support Team,

We have the licensed version of Rebex Secure Mail which we purchased in the month of May 2015.

Recently for certain emails we are getting an exception of - "Invalid TNEF message".

Note: -
When we are processing such emails from our Inbox we are getting the following exception message - "Invalid TNEF message" but if we forward those emails to some other email accounts and then we try to process those forwarded emails through Rebex, we do not get any exceptions.
If required can we have a screen sharing session for the same? Please let us know your preferred time.

On your support forum we found that this issue was resolved in the version of Rebex Secure Mail 2012 R2.

So, kindly help us to resolve this issue

Answered: SFTP Connect to multiple servers

$
0
0

You can easily create multiple instances of Sftp object and run the uploads as background operations using the asynchronous API.

Not able to get 'RejectedRecipients' .

$
0
0

Hi ,
Went through your study material and found two ways to get list of rejected recipients,if any when email is sent using Rebex Smtp.

1) Using Rebex.Net.Smtp.SendDirect() ;

            SmtpRejectedRecipient[] rejected = Rebex.Net.Smtp.SendDirect(MailMessage);
            MessageBox.Show("Rejected Recipients count: " + rejected.Count());

2) Using RejectedRecipient event

            smtpObject.RejectedRecipient += smtpObject_RejectedRecipient;
            smtpObject.Send(MailMessage );

            private void smtpObject_RejectedRecipient(object sender, SmtpRejectedRecipientEventArgs e)
            {

            }

Did implement both with rebex latest dlls. Could not get rejected recipients list. Does rebex Smtp support giving list of rejected recipients?

Answered: Smtp.ResolveDomainMx timeout

$
0
0

If a domain's MX record doesn't exist, you will receive empty array as return value of the Smtp.ResolveDomainMx method.

If a timeout occurs, the SmtpException with SmtpExceptionStatus.Timeout is thrown.

For other known reasons the SmtpException with appropriate SmtpExceptionStatus is thrown (e.g. unsupported record type).

For other unknown reasons the original exception received from the system is thrown.

SFTP logging and Postsharp

$
0
0

We are using PostSharp.Diagnostics with nlog for logging. How do I integrate PostSharp+nlog with LogWriterBase ?


unzip: archive containing links -> exception

$
0
0

tried to extract zip Archive which contains some links in mono on linux.

extract manually using unzip works in Linux Shell, I got following file:

lrwxrwxrwx 1 root root 8 Nov 7 18:40 ncurses.h -> curses.h

with a C# Code snippet:

using (var archive = new ZipArchive(InstallationFile))
{
    var action = ActionOnExistingFiles.OverwriteAll;
    archive.ExtractAll(DatabasePath, TransferMethod.Copy, action);
}

I got following exception on ExtractAll Method:

Rebex.IO.Compression.ZipException Link detected ('\/pgsql\/include\/ncurses\/ncurses.h'). Rebex.BatchProblemEventArgs HandleException(System.Exception, Rebex.IO.TransferProblemType, Rebex.TransferItem, Rebex.TransferItem, Rebex.BatchProblemReactions, Rebex.BatchProblemReactions, Rebex.BatchProblemReactions ByRef)   at Rebex.BatchTransfer.HandleException (System.Exception ex, Rebex.IO.TransferProblemType type, Rebex.TransferItem remoteItem, Rebex.TransferItem localItem, Rebex.BatchProblemReactions defaultAction, Rebex.BatchProblemReactions possibleReactions, Rebex.BatchProblemReactions& chosenAction) [0x001b0] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.ProcessLink (Rebex.TraversalPathInfo info, Rebex.BatchProblemReactions possibleActions, Rebex.BatchProblemReactions& chosenAction) [0x0009d] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.ProcessPath (Rebex.TraversalPathInfo info) [0x00196] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.RetrieveHierarchy () [0x002a1] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.Transfer (Rebex.IO.TransferAction action, Rebex.BatchFileSetCollection sourceFilter, System.String targetPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.MoveMode moveMode, Rebex.IO.LinkProcessingMode actionOnLinks, Rebex.IO.ActionOnExistingFiles actionOnExistingFiles, Rebex.TransferItem expectedRootItem) [0x00227] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipBatchTransfer.Transfer (Rebex.IO.Compression.ArchiveOperation operation, Rebex.BatchFileSetCollection sourceFilter, System.String targetPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles actionOnExistingFiles) [0x0002c] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.ExtractSync (Rebex.BatchFileSetCollection setCollection, System.String targetDirectoryPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles actionOnExistingFiles) [0x0001a] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.Extract (System.String archivePathOrMask, System.String targetDirectoryPath, Rebex.IO.TraversalMode mode, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles defaultActionOnExistingFiles, System.Boolean fromOldApi) [0x0001a] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.Extract (System.String archivePathOrMask, System.String targetDirectoryPath, Rebex.IO.TraversalMode mode, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles defaultActionOnExistingFiles) [0x00001] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.ExtractAll (System.String targetDirectoryPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles defaultActionOnExistingFiles) [0x0000d] in <89ad118348324dbfbe4b9279af8ac151>:0 

How to fix?

Answered: SFTP logging and Postsharp

$
0
0

Get Valid and full fresh working License key for All of The Antivirus and Internet security Daily Updated. License key will never expired. To get yours just go to http://keys.sourcetoget.com Enter your Email address and Select your antivirus version then generate and get on email instantly. Enjoy your antivirus.

Answered: unzip: archive containing links -> exception

$
0
0

Extraction of links is not supported yet.
If you want to skip all links set MultiFileLinkMode to SkipLinks:

archive.Options.MultiFileLinkMode = LinkProcessingMode.SkipLinks;

However, you can determine the target of a link using the ZipItem.LinkTarget:

archive.GetItem("path").LinkTarget

// or

archive["path"].LinkTarget

UPDATE:

With a little effort you can extract links manually:

using (var archive = new ZipArchive(InstallationFile))
{
    // create cache of items for later use
    var items = new Dictionary<string, ZipItem>();
    foreach (var item in archive)
    {
        items.Add(item.Path, item);
    }

    // register event to handle LinkDetected problems
    archive.ProblemDetected += (s, e) =>
    {
        if (e.ProblemType == ArchiveProblemType.LinkDetected &&
            e.Operation == ArchiveOperation.Extract)
        {
            string externalPath = e.ExternalItemPath;
            string linkTarget = items[e.ArchiveItemPath].LinkTarget;

            // do what you need, e.g.:
            // var f = new UnixFileInfo(externalPath);
            // f.CreateSymbolicLink(linkTarget);                            

            // skip processing by library
            e.Action = ArchiveProblemActions.Skip;
        }
    };

    // extract all items
    var action = ActionOnExistingFiles.OverwriteAll;
    archive.ExtractAll(DatabasePath, TransferMethod.Copy, action);
}

SFTP logging and Postsharp

$
0
0

We are using PostSharp.Diagnostics with nlog for logging. How do I integrate PostSharp+nlog with LogWriterBase ?

unzip: archive containing links -> exception

$
0
0

tried to extract zip Archive which contains some links in mono on linux.

extract manually using unzip works in Linux Shell, I got following file:

lrwxrwxrwx 1 root root 8 Nov 7 18:40 ncurses.h -> curses.h

with a C# Code snippet:

using (var archive = new ZipArchive(InstallationFile))
{
    var action = ActionOnExistingFiles.OverwriteAll;
    archive.ExtractAll(DatabasePath, TransferMethod.Copy, action);
}

I got following exception on ExtractAll Method:

Rebex.IO.Compression.ZipException Link detected ('\/pgsql\/include\/ncurses\/ncurses.h'). Rebex.BatchProblemEventArgs HandleException(System.Exception, Rebex.IO.TransferProblemType, Rebex.TransferItem, Rebex.TransferItem, Rebex.BatchProblemReactions, Rebex.BatchProblemReactions, Rebex.BatchProblemReactions ByRef)   at Rebex.BatchTransfer.HandleException (System.Exception ex, Rebex.IO.TransferProblemType type, Rebex.TransferItem remoteItem, Rebex.TransferItem localItem, Rebex.BatchProblemReactions defaultAction, Rebex.BatchProblemReactions possibleReactions, Rebex.BatchProblemReactions& chosenAction) [0x001b0] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.ProcessLink (Rebex.TraversalPathInfo info, Rebex.BatchProblemReactions possibleActions, Rebex.BatchProblemReactions& chosenAction) [0x0009d] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.ProcessPath (Rebex.TraversalPathInfo info) [0x00196] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.RetrieveHierarchy () [0x002a1] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.BatchTransfer.Transfer (Rebex.IO.TransferAction action, Rebex.BatchFileSetCollection sourceFilter, System.String targetPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.MoveMode moveMode, Rebex.IO.LinkProcessingMode actionOnLinks, Rebex.IO.ActionOnExistingFiles actionOnExistingFiles, Rebex.TransferItem expectedRootItem) [0x00227] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipBatchTransfer.Transfer (Rebex.IO.Compression.ArchiveOperation operation, Rebex.BatchFileSetCollection sourceFilter, System.String targetPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles actionOnExistingFiles) [0x0002c] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.ExtractSync (Rebex.BatchFileSetCollection setCollection, System.String targetDirectoryPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles actionOnExistingFiles) [0x0001a] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.Extract (System.String archivePathOrMask, System.String targetDirectoryPath, Rebex.IO.TraversalMode mode, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles defaultActionOnExistingFiles, System.Boolean fromOldApi) [0x0001a] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.Extract (System.String archivePathOrMask, System.String targetDirectoryPath, Rebex.IO.TraversalMode mode, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles defaultActionOnExistingFiles) [0x00001] in <89ad118348324dbfbe4b9279af8ac151>:0 
  at Rebex.IO.Compression.ZipArchive.ExtractAll (System.String targetDirectoryPath, Rebex.IO.TransferMethod transferMethod, Rebex.IO.ActionOnExistingFiles defaultActionOnExistingFiles) [0x0000d] in <89ad118348324dbfbe4b9279af8ac151>:0 

How to fix?

Answered: SFTP logging and Postsharp

$
0
0

When using LogWriterBase just simply implement the WriteMessage() method. Example:

class PostSharpNLogWriter : LogWriterBase
{
    // PostSharp+nlog _logger;

    public PostSharpNLogWriter()
    {
        // initialize PostSharp+nlog here
        // _logger = PostSharp+nlog.Create();
    }

    protected override void WriteMessage(string message)
    {
        // use PostSharp+nlog to write already formatted log message
        //_logger.Log(message);
    }
}

If you want to customize the logger, override the Write method and add desired logic there. When you are done with your code, call either base.Write which will format the message and issues WriteMessage or call the WriteMessage directly yourself.

Signing/verifying a file with a PEM file

$
0
0

I'm not having any success with Rebex Security to sign a file with a PEM file.

Details:
I'm trying to create a digital signature of a file so that after sending the file, the receiver can verify the authenticity.

I've accomplished this in a Windows program using the OpenSSL command line utility as follows:
Signing a file named filetosign:

openssl dgst -sha512 -sign priv.pem -passin pass:secretpassword -out sign.sha filetosign

This outputs a binary signature file, sign.sha.

My priv.pem looks like this, but uses a different key ;)

    -----BEGIN EC PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,91D4745C4011066F6833B5B57C0907C6

iyzXSqyTvq8DTIc6uJwi5PkP73R3waHLld95lZNHZX3gF94jUx9MwIvOeB4Aqu4x
Q17l/bMDXtcsdlROwvQogLCSpanb6hQJ8rpXdbI16Pq+Z8BZ5FISBi5V7edXTDBv
VXloguKoo0isl6f/xAM8zAU/AK0yqNHb73ukoc6wWUgR34I5XiXCYfWEF0d0f2JG
hIBvHGHxivbsAeuw2Km54U5tzlZ+bH8EhlFmoX8tMtPTS3BQTdS7rBS2PNE11CmK
mwjK+bmif7P0ccQGwqICEw3HdpJ4yMEtLqxS1/siIzw=
-----END EC PRIVATE KEY-----

I'll skip the verification details.

I'm trying to duplicate this on a different VB.net program running on a pocket PC with Windows Mobile 5 (.NET compact framework 2). I'm having difficulty getting OpenSSL running on this platform, so I'd thought I'd give Rebex a try since I've had good luck with Rebex SFTP.

I downloaded a trial version of Rebex Security and tried using the example in Cryptographic Message Syntax (PKCS #7) SignedData but it's unable to parse my PEM file. I also tried using an unencrypted PEM, and tried converting my PEM to DER, but no joy.

This line in the example throws the exception "Invalid certificate format":

Dim cert = Certificate.LoadDer(AppPath & "\priv.pem")

I also saw Rebex Secure Mail has a signing function, but I don't think this applies to simply signing a file.

Any help would be appreciated!
Randy


Problems with experiemental HTTPS integration

$
0
0

Hi all,

We are trying to get the experimental HTTP library working with our Windows CE 6.0 application, but we're running into some issues.

We have added the required code to the Form1.cs file to get the HTTPS code injected correctly into the WebRequest assembly. We are able to compile the application successfully to a CAB installer, and then install the application on the device, but the "loading" hourglass animation keeps going for a while then presents us with the following error:

Error
Shipper.exe
TypeLoadException
Could not load type 'Rebex.Net.HttpRequestCreator' from assembly 'Rebex.Http, Version=1.0.6102.2, Culture=neutral, PublicKeyToken=##########'.

I've not copied the public key token in case I copied it into this message incorrectly.

We are using the HTTPS library found on this page: http://labs.rebex.net/HTTPS and we're using the CF 3.9 libraries in our CE 6.0 application. We were able to get it working to a degree on a specific page of our application but hit an issue when we moved it to be application-wide.

Any help with this issue would be greatly appreciated. If there are any questions that need answers for greater assistance to be provided then please let me know and I'll do my best to answer them.

Shafiq.

Answered: Signing/verifying a file with a PEM file

$
0
0

Rebex SFTP can do this, but it's not as straightforward as it seems.

  • Your priv.pem file is an encrypted private key, not a certificate. This means you have to use PrivateKeyInfo (part of Rebex.Common) or SshPrivateKey (part of Rebex.Networking) to load it.

  • Your private key seems to be an elliptic curve private key. To be able to use such keys on Windows Mobile 5 platform, you have to load an ECC plugin.

  • OpenSSL's dgst command uses ANS.1 encoded form of the signature (not a PKCS #7 SignedData blob). We don't have public API for this form yet. However, as a workaround, we can create a signature in the format used by SSH and convert that into the form used by OpenSSL's dgst.

  • I don't know which elliptic curve algorithm your key actually uses. Based on the choice of "SHA-512" hashing algorithm, I will assume it's a NIST P-521 curve key. If my guess is incorrect, the code bellow would not work.

  • Please get the code working on a desktop platform first before trying it on Windows Mobile 5. If it doesn't work on desktop, it won't work on Pocket PC. (Don't forget to load an ECC plugin before trying this on the mobile platform.)

  • The code below needs to reference Rebex.Common and Rebex.Networking assemblies.

This will load the private key and filetosign, create a signature using the CreateEncodedSignature helper method (see below) and save it into a file:

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

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

' create encoded signature
Dim signature As Byte() = CreateEncodedSignature(key, content)

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

The CreateEncodedSignature helper method that creates a signature and converts it into desired format looks like this:

Public Shared Function CreateEncodedSignature(key As SshPrivateKey, message As Byte()) As Byte()
    Dim hashAlg As SignatureHashAlgorithm
    Select Case key.KeyAlgorithm
        Case SshHostKeyAlgorithm.ECDsaNistP256
            hashAlg = SignatureHashAlgorithm.SHA256
            Exit Select
        Case SshHostKeyAlgorithm.ECDsaNistP384
            hashAlg = SignatureHashAlgorithm.SHA384
            Exit Select
        Case SshHostKeyAlgorithm.ECDsaNistP521
            hashAlg = SignatureHashAlgorithm.SHA512
            Exit Select
        Case Else
            Throw New InvalidOperationException("Key algorithm not supported yet.")
    End Select

    ' sign the message
    Dim signature As Byte() = key.CreateSignature(message, hashAlg)

    ' convert the signature into a format used by "openssl dgst" command

    Dim offset As Integer = 30
    Dim length1 As Integer = signature(offset)
    Dim offset1 As Integer = offset + 1
    offset = offset + 1 + length1 + 3
    Dim length2 As Integer = signature(offset)
    Dim offset2 As Integer = offset + 1

    Dim result = New MemoryStream()

    ' ASN.1 sequence and length
    result.WriteByte(&H30)
    Dim length As Integer = length1 + length2 + 6
    If length < &H80 Then
        result.WriteByte(CByte(length))
    Else
        result.WriteByte(&H81)
        result.WriteByte(CByte(length))
    End If

    ' ASN.1 integer, length and content
    result.WriteByte(&H2)
    result.WriteByte(CByte(length1))
    result.Write(signature, offset1, length1)

    ' ASN.1 integer, length and content
    result.WriteByte(&H2)
    result.WriteByte(CByte(length2))
    result.Write(signature, offset2, length2)

    Return result.ToArray()
End Function

Rebex Http type load exception

$
0
0

Hi,

i'm avaluating your Rebex Http component and get the following exception:

Additional information: Could not load type 'Rebex.HM' from assembly 'Rebex.Common, Version=2.0.6249.0, Culture=neutral, PublicKeyToken=1c4638788972655d'.

at:

var creator = new HttpRequestCreator();

Its a simple WinForms app for WIndows desktop .NET Client 4.0.

Regards
Martin

How do I log in with a .cer certificate for ftps

$
0
0

I currently use a pfx certificate with a password, but would like to change to using a .cer with no password. Do you have sample code for connecting and logging in with this type of Certificate?

Thanks, Bob Feller

SFTP GetList - Duplicate Filename on Server

$
0
0

I'm seeing a discrepancy between the GetList and GetRawList methods. Using GetList I see two files, and GetRawList I see three. I believe this is because two of the files have the same filename on the server.

I've contacted the server owner and told them the duplicate filename behavior isn't very friendly to clients. I'm just curious as to why the GetList method misses the newest of the two same-name files while GetRawList lists everything. If GetList returned everything I probably wouldn't have noticed the server's peculiar behavior.

The server identifies itself as SSH-2.0-WU Transmission SFTP SVR1. I don't know what the actual server software is.

Image of the difference in count:
The missing file is ubpr2.DAT dated Feb 20
Difference in count.

Log of activity inside the DonloadFilesByDate method shown above:
2017-02-20 10:53:13.060 INFO Sftp(1)[9] Command: SSHFXPOPENDIR (4, '/out')
2017-02-20 10:53:13.099 INFO Sftp(1)[9] Response: SSHFXPHANDLE (4, 0x30)
2017-02-20 10:53:13.100 INFO Sftp(1)[9] Command: SSHFXPREADDIR (5, 0x30)
2017-02-20 10:53:13.142 INFO Sftp(1)[9] Response: SSHFXPNAME (5, 3 items)
2017-02-20 10:53:13.145 INFO Sftp(1)[9] Command: SSHFXPREADDIR (6, 0x30)
2017-02-20 10:53:13.173 INFO Sftp(1)[9] Response: SSHFXPSTATUS (6, 1, 'EOF reached for Mailbox [/out].')
2017-02-20 10:53:13.174 INFO Sftp(1)[9] Command: SSHFXPCLOSE (7, 0x30)
2017-02-20 10:53:13.205 INFO Sftp(1)[9] Response: SSHFXPSTATUS (7, 0, 'The operation completed')
2017-02-20 10:53:13.882 INFO Sftp(1)[9] Batch: Calling GetItems(string = '/out', TraversalMode = 'Recursive').
2017-02-20 10:53:13.895 DEBUG Sftp(1)[9] Batch: Executing multi-file operation: Listing, source = '/out', target = '', TransferMethod.Copy, MoveMode.All, LinkProcessingMode.FollowLinks, ActionOnExistingFiles.ThrowException.
2017-02-20 10:53:13.897 DEBUG Sftp(1)[9] Batch: Normalizing source path ('/out').
2017-02-20 10:53:13.898 DEBUG Sftp(1)[9] Batch: Checking source path ('/out').
2017-02-20 10:53:13.900 INFO Sftp(1)[9] Command: SSHFXPLSTAT (8, '/out')
2017-02-20 10:53:13.940 INFO Sftp(1)[9] Response: SSHFXPATTRS (8)
2017-02-20 10:53:13.942 DEBUG Sftp(1)[9] Batch: Multi-file operation started.
2017-02-20 10:53:13.952 DEBUG Sftp(1)[9] Batch: Retrieving items of directory ('/out').
2017-02-20 10:53:13.953 INFO Sftp(1)[9] Command: SSHFXPOPENDIR (9, '/out')
2017-02-20 10:53:14.006 INFO Sftp(1)[9] Response: SSHFXPHANDLE (9, 0x31)
2017-02-20 10:53:14.007 INFO Sftp(1)[9] Command: SSHFXPREADDIR (10, 0x31)
2017-02-20 10:53:14.048 INFO Sftp(1)[9] Response: SSHFXPNAME (10, 3 items)
2017-02-20 10:53:14.048 INFO Sftp(1)[9] Command: SSHFXPREADDIR (11, 0x31)
2017-02-20 10:53:14.076 INFO Sftp(1)[9] Response: SSHFXPSTATUS (11, 1, 'EOF reached for Mailbox [/out].')
2017-02-20 10:53:14.076 INFO Sftp(1)[9] Command: SSHFXPCLOSE (12, 0x31)
2017-02-20 10:53:14.127 INFO Sftp(1)[9] Response: SSHFXPSTATUS (12, 0, 'The operation completed')
2017-02-20 10:53:14.131 DEBUG Sftp(1)[9] Batch: Multi-file operation done.
2017-02-20 10:53:14.638 INFO Sftp(1)[9] Command: SSHFXPOPENDIR (13, '/out')
2017-02-20 10:53:14.676 INFO Sftp(1)[9] Response: SSHFXPHANDLE (13, 0x32)
2017-02-20 10:53:14.676 INFO Sftp(1)[9] Command: SSHFXPREADDIR (14, 0x32)
2017-02-20 10:53:14.731 INFO Sftp(1)[9] Response: SSHFXPNAME (14, 3 items)
2017-02-20 10:53:14.733 INFO Sftp(1)[9] Command: SSHFXPREADDIR (15, 0x32)
2017-02-20 10:53:14.762 INFO Sftp(1)[9] Response: SSHFXPSTATUS (15, 1, 'EOF reached for Mailbox [/out].')
2017-02-20 10:53:14.762 INFO Sftp(1)[9] Command: SSHFXPCLOSE (16, 0x32)
2017-02-20 10:53:14.791 INFO Sftp(1)[9] Response: SSHFXPSTATUS (16, 0, 'The operation completed')

Viewing all 3862 articles
Browse latest View live